zRSSFeed unable to load feeds with GET Parameters

zRSSFeed is a nice little RSS Reader for jQuery which uses Google’s Feeds API to parse the RSS Feed.

However if your RSS URL contains required GET variables you’ll find zRSSFeed will just display: “Feed could not be loaded.” – Or similar (if you’ve changed the default error message). There is however a really easy fix, although you will probably want to make the change in the non-minified version of the source and then re-minify. Change line 46 from:

var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + url;

To:

var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url);

This encodes the URL to allow it to be embedded as a GET parameter. (See MDN for more info…)

Edit:

Another thing I noticed with zRSSFeed is it won’t load the feed from Google over SSL if your site is using https. However this is easily fixed just modify the same line as above, from:

var api = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url);

To:

var api = location.protocol + "//ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url);
  • Duck

    Thanks, very useful!