最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Get Data from a Web Page, then Display It On Another Web Page - Stack Overflow

programmeradmin5浏览0评论

I want to get data from an HTML web page, then display it in a Div on another HTML web page, with jQuery.

I tried jQuery's get(), load(), and ajax() methods, but unable to get the data. Here is my code:

/

  • What's wrong with my code?

  • Is it possible to get data from an ASP.NET web page, then display it on an HTML web page?

  • How to get data from a Div in a web page, then display it in another Div on another web page?

Thanks in advance...

I want to get data from an HTML web page, then display it in a Div on another HTML web page, with jQuery.

I tried jQuery's get(), load(), and ajax() methods, but unable to get the data. Here is my code:

http://jsfiddle/YcprC/

  • What's wrong with my code?

  • Is it possible to get data from an ASP.NET web page, then display it on an HTML web page?

  • How to get data from a Div in a web page, then display it in another Div on another web page?

Thanks in advance...

Share Improve this question asked Feb 18, 2012 at 11:58 BayuBayu 4672 gold badges10 silver badges19 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 4

You can not get data from other websites because of what is know as Same Origin Policy:

In puting, the same origin policy is an important security concept for a number of browser-side programming languages, such as JavaScript. The policy permits scripts running on pages originating from the same site to access each other's methods and properties with no specific restrictions, but prevents access to most methods and properties across pages on different sites.1

To workaround that, you should implement JSONP. Learn more about it here.

Or you may also use Yahoo's YQL, see:

  • Quick Tip: Cross Domain AJAX Request with YQL and jQuery

You can't do this because of crossdomain security policies. I remend you load the webpages data with PHP (easy way is file_get_contents, pro way is curl) and load that php with your jquery.

Same domain - simple. Cross-domain - difficult. Not natively supported except in old versions of IE (5.5 and 6)

If the page being scraped is small enough then you can use the Yahoo Pipes service to fetch the information and pass it back to the app as a JSON string. For anything bigger or more plicated use the Google App Engine or run the php fetching of data through a free web Host.

发布评论

评论列表(0)

  1. 暂无评论