I'm transitioning my personal search suggestions from google to duckduckgo, but I'm missing something simple to make it work. I'm using jQuery-UI's autocomplete framework.
My search form
<form action="https://duckduckgo.com/?q=" method="post" id="search">
<input type="text" name="query" value="" autocomplete="off">
<button type="submit">Search</button>
</form>
My jQuery
$( "#search input[type=text]" ).autocomplete(
{
delay: 0,
minLength: 1,
position: { my: "left top-3" },
source: function( request, response )
{
// var suggestURL = "https://www.google.com/complete/search?client=firefox&q=%QUERY";
var suggestURL = "https://duckduckgo.com/ac/?q=%QUERY&type=list";
suggestURL = suggestURL.replace( "%QUERY", request.term );
$.ajax({
method: "GET",
dataType: "jsonp",
jsonpCallback: "jsonCallback",
url: suggestURL,
success: function( data )
{
response( data[1] );
},
error: function( jqXHR, textStatus, errorThrown )
{
console.log( textStatus, errorThrown );
}
}
});
The query for google returns:
https://suggestqueries.google.com/complete/search?client=firefox&q=foobar&callback=jsonCallback&_=1600956954436
jsonCallback && jsonCallback(["foobar",["foobar","foobar meaning","foobar google","foobar challenge","foobar2000 skins","foobar2k","foobar2000 themes","foobar2000 download","foobar2000 mac","foobar themes"],[],{"google:suggestsubtypes":[[433],[],[],[],[],[],[],[],[],[]]}])
The query for duckduckgo returns:
https://ac.duckduckgo.com/ac/?q=foobar&type=list&callback=jsonCallback&_=1600956892202
["foobar",["foobar2000","foobar","foobar2000 download","foobar ape","foobar2000 layout","foobar2000 decoder","foobar2000 tak","foobar2000 dsp"]]
The difference between the two seems to be jsonCallback && jsonCallback([data])
is included in the google query and I don't understand why they're different or how to fix it.
EDIT 1
After adding some error handling to the js, the error I'm getting is:
parsererror Error: jsonCallback was not called
EDIT 2
After digging into this a bit more, I don't think DDG's server allows it. It's my understanding that their server needs to send an appropriate response and I don't think it's doing so.