JQuery Get related summary analysis of Cross-domain XML (RSS) data _jquery

Source: Internet
Author: User

The previous time project, need front-end JS get cross-domain XML (RSS), first intend to use the Jquery.ajax method to obtain, but under IE9, hint "denied access" slightly embarrassed, online search related data summarized the following methods:

One, Google's jgfeed: I believe that many students should not unfamiliar to this, the use is relatively simple:

Source:

(function ($) {
 $.extend ({
  jgfeed:function (URL, fnk, num, key) {
   //Make sure URLs to get are 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);
})

Second, Yahoo's yql query; this way may be some students do not know much, and do not say please look down:

var yqlurl= ' http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3d ' +xml or RSS path + ' &format=json&diagnostics=true&callback=? '
$.getjson (yqlurl,function (data) {
	console.log (data)
})

The above yqlurl is the Yahoo YQL console to copy down, as long as oneself replaces the corresponding file path.

Here is a recommended Yahoo yql control address, there are a lot of fun things (get weather, Woeid, cross-domain data, etc.), you can return XML and JSON two of results.

The above jquery get cross domain XML (RSS) data related summary analysis is small series to share all the content, hope to give you a reference, also hope that we support cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.