I have this code :
$(document).ready(function(){
$("#search_input").autocomplete({
source: function(request, response) {
$.ajax({
url: 'http://query.yahooapis.com/v1/public/yql',
dataType: 'JSONP',
data: {
format: 'json',
q: 'select * from xml where url="http://google.com/complete/search?hl=nl&output=toolbar&q=' + encodeURIComponent(request.term) + '"'
},
success: function(data) {
response($.map(data.query.results.toplevel.CompleteSuggestion, function(item) {
return { label: item.suggestion.data, value: item.suggestion.data };
}));
}
});
}
});
});
For some reason it doesn’t work with Jquery 1.4 but it does with 1.7 Is this becouse JSONP was not introduced with 1.4? How can I make it work with 1.4?
Here is the Fiddle JsFiddle
Demo: http://jsfiddle.net/TnPRA/2/
You’ve got two problems:
The correct usage is to select
jQuery ____at UseChoose framework,The critical part of your code is caused by jQuery itself:
In jQuery 1.4, the response is a string. To get the code to work in older jQuery versions, add one line to the
successhandler: