jQuery-Autocomplete icon indicating copy to clipboard operation
jQuery-Autocomplete copied to clipboard

Autocomplete ignores serviceURL and returns “self” instead

Open KenBotwinick opened this issue 1 year ago • 0 comments

Trying to implement a simple devbridge autocomplete which uses a .php file to query MySQL:

$("#theories").devbridgeAutocomplete({ serviceURL: 'theorySearch.php', paramName: 'theories' });

Was constantly getting the following in the console when testing the text input field:

Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

I had manually tested the .php file by accessing it directly with the query string in the URL and it returns exactly the right format expected, so it seemed autocomplete was getting the wrong response.

To better figure out what the problem was, I modified the autobridge .js to show the response in the console:

function _transformResult(response) { console.log(response); // added debugging // the following line is the parseJSON that returns the error return typeof response === 'string' ? $.parseJSON(response) : response; }

The response was the script section of the originating page where this is all defined:

`

KenBotwinick avatar Jun 14 '24 21:06 KenBotwinick