Using Gdata with jQuery

This morning, I had the unbearable desire to find out why I can’t call Google’s AJAX Feed API with jQuery 1.2.3 directly, but using a small proxy script. In theory, it’s just including a script tag which then loads the remote JavaScript and executes a callback function (thus, bypassing the same-origin policy of JavaScript, which would apply for a normal XMLHttpRequest):



$.get(‘’, null, someCallbackFunction, ‘jsonp’);

What did work quite well was


feed.php is a small PHP script that outputs the example blog feed above. So it wasn’t a problem with the data format or the cross-domain requests.

What happens? jQuery’s ajax function has a config parameter called ‘cache’. If it’s set to false (or not set), then a timestamp parameter will be added automatically to all URLs:

Google doesn’t like additional parameters and just returns: Invalid query parameters:_

This can be easily fixed by setting $.ajaxSettings.cache = true

Still, I did not get any results. Of course I could call the feed URL in the browser, but it did not work with jQuery as expected. The end of the story was to disable the AdBlockPlus (ABP) plugin of Firefox. For one reason or another, probably all script calls to something with the string “adwords” in it will be blocked, it did not allow the URL to be included as script.

Others seem to have similar problems.

You might also want to have a look at the jQuery Google Feed Plugin. Google itself uses jQuery on Google Code.