JQuery obtains the summary and analysis of cross-origin XML (RSS) data, jqueryxml
Some time ago, the project requires front-end JS to obtain cross-origin XML (RSS). First, we plan to use jQuery. the ajax method is obtained, but the prompt "Access Denied" is a little embarrassing below ie9. The following methods are summarized by searching relevant information on the Internet:
I. google's jGFeed: I believe many people should be familiar with this and use it relatively easily:
Source code:
(function($){ $.extend({ jGFeed : function(url, fnk, num, key){ // Make sure url to get is defined if(url == null) return false; // Build Google Feed API URL var gurl = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q="+url; if(num != null) gurl += "&num="+num; if(key != null) gurl += "&key="+key; // AJAX request the API $.getJSON(gurl, function(data){ if(typeof fnk == 'function') fnk.call(this, data.responseData.feed); else return false; }); } });})(jQuery);
Call:
JQuery. jGFeed ('xml or RSS path', function (feeds) {console. log (feeds );})
Ii. query YQL of yahoo. Some people may not know much about this method, so please refer to it below:
Var YqlUrl = 'HTTP: // query.yahooapis.com/v1/public/yql? Q = select % 20 * % 20 from % 20xml % 20 where % 20url % 3D "'+ XML or RSS path +'" & format = json & diagnostics = true & callback =? '$. GetJSON (YqlUrl, function (data) {console. log (data )})
The above YqlUrl is copied from the yahoo YQL console. You only need to replace the corresponding file path.
Here we recommend the address controlled by Yahoo YQL, which contains many interesting things (getting weather, WOEID, cross-Origin data, etc.) and can return XML and JSON results.
The above jQuery summary and analysis of cross-origin XML (RSS) data is all the content shared by Alibaba Cloud. I hope you can give us a reference and support for our customer base.