Jquery bug ? - getjson

hip_hop_x

Regular Member
Joined
Aug 27, 2009
Messages
305
Reaction score
65
Hey there so i got into abit of trouble

The problem i am facing is that it never get's to the function(data,status)... and bugzilla reports that the call to that page is being made, also that response status is 200, and that there is a response.
So why $.getJSON doesn't recognize it (also did try with $.ajax, same crap), i mean why it doesn't go to the function (data,status) when it is supposed to get there?

PHP:
function suggest(kw){
console.log("Logging!");
$.getJSON('http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl=en-US&callback=?&q='+kw,
 function(data,status){
  $.each(data, function(i,item){alert(item.x);});
});
}

If anyone has clue/fix let me know, thank you!
 
It 's a cross-domain request, it will never receive the response ;)

In short, you can't make it work without server side code to fetch the result for you.
 
If you are using cross domain your browser might be blocking it?

What 's the chances of him being the owner of suggestqueries.google.com ? :D:D
 
it's jsonp, so i can request thou any cross domain wich has a callback, and from bugzilla i see that i get a response, just that $.getJSON or $.ajax (type:jsonp) doesn't recognize the function (data) nor the success: function(data)...

Any suggestions?


Basicly cross domain isn't the case here, because i get the data, just that the js doesn't know where to parse it.
 
Last edited:
it's jsonp
nah, your url gives you pure json back
to make it work you have to change the the client to youtube (chrome works also):
Code:
function suggest(kw){
    console.log("Logging!");
    $.getJSON('http://suggestqueries.google.com/complete/search?[color=red]client=youtube[/color]&hl=en-US&callback=?&q='+kw,
        function(data,status){
            console.log(data);
            $.each(data[1], function(i,item){alert(item[0]);});
    });
}
 
oh, thanks mate, you saved me from allot of trouble. The main problem why i choose to do this by client side is that it's saving time and it's not using server ip all the time to querry google suggestions.
 
Back
Top