开发者

How to read an external html page using jquery?

开发者 https://www.devze.com 2023-03-13 00:55 出处:网络
I am using .ajax function to read data from an external page . I am not able to read the page and I get the exception as Access Control Allow origin.

I am using .ajax function to read data from an external page . I am not able to read the page and I get the exception as Access Control Allow origin. i want to show the data of another page in my page I even set crossdomain:true but it dint help

  $.ajax({
type: "GET",   url: myurl,
dataType: "html",
 crossDomain:true,
success:parsehtml});

How to read an external html page using jqu开发者_StackOverflow社区ery ?


The underlying Javascript engines in most modern browsers don't permit Cross-Domain transactions. You will have to use a server-side language such as PHP to do this. Mozilla has a fairly decent description of this issue.


There is one solution without using any server side technologies. Please see this http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-cross-domain-ajax-request-with-yql-and-jquery/

You may have to process the returned output to suit your need.

0

精彩评论

暂无评论...
验证码 换一张
取 消