问题
I want to set up some tabbed content on my site using jQuery and I want the tabs to pull the rss feeds from another part of the site. It's still the same site, though. Is this possible?
回答1:
If the XML documents are on the same domain as your document it can be done with jQuery.ajax() calls, or you can use jQuery plugins to fetch and parse data with jQuery RSS plugins.
If they are on a different domain you can use Yahoo Pipes to transform the remote XMLs to JSONP response which will work with all browsers, or you can use Cross-Origin Resource Sharing (cross domain AJAX) with the new ones.
回答2:
You cant pull cross domain contents. You may use JsonP if the data is available in that format. You can use Yahoo YQL to create a JsonP representation for the rss feed and then call that as yql query using jquery's ajax method. Here is sample yql to convert the rss feed to json format
yql = select * from rss where url ="<feed url>"
and you can use the following url as parameter to ajax/json function in jquery
http://query.yahooapis.com/v1/public/yql?q=yql&format=json&callback=rssLoaded
回答3:
If you want to process the information, and output it in a different way this should be done through PHP with the use of something like cURL
来源:https://stackoverflow.com/questions/5800769/how-do-i-pull-rss-feeds-into-jquery-tabs