I am trying to implement eBay autosuggest in an opera extension using jQuery autocomplete.
eBay's JSON URL is: http://anywhere.ebay.com/services/suggest/?v=jsonp&q=test
And this is what it gives:
["test",["tube tester","testosterone","battery tester","tester","diamond tester","testoni","one touch ultra test strips","testors"]]
But it doesn't parse anything. What I'm I missing?
With a php file which handle the json call.
Here is the javascript :
$("input").autocomplete({
source: function(request, response) {
$.ajax({
url: "ajax.php",
dataType: "json",
data: {
"v" : "jsonp",
"q" : request.term
},
success: function (data) {
response(data[1]);
}
});
}
});
and the ajax.php
<?php
$v = $_GET['v'];
$q = $_GET['q'];
echo file_get_contents("http://anywhere.ebay.com/services/suggest?v=$v&q=$q");
?>
I assume jQuery ajax() doesn't support "jsonp" datatype, because it was the problem all along.
You still have the same response in json though.