Search code examples
jquerygoogle-custom-search

getJSON silent error?


I'm making a request to Google Custom Search using getJSON. FireBug is showing that it's returning a 200 OK. However, my callback function never happens.

The jQuery docs mention a silent error, which I suppose makes sense, yes? I'm not surprised Google would with a format error.

http://api.jquery.com/jQuery.getJSON/

How can trouble shoot this? Is there a workaround? I saw something about using AJAX instead but I can't seem to nail down the necessary details.

btw, if I copy the GET request URL out of Firebug and paste it into the browser I get results. But in Firebug results is blanks/empty. I'm stumped.


Solution

  • The first thing I would check is that your request is using the JSONP protocol. Your URL should have the "callback=?" parameter included. JSONP is required for all cross-domain JSON requests.

    If you are still having issues I would take a look at the return data in the debugger and post that here for others to review.

    SEE THIS POST FOR YOUR SOLUTION: Access-Control-Allow-Origin error sending a jQuery Post to Google API's