开发者

XMLHttpRequest cannot load http://www.reddit.com/.xml

开发者 https://www.devze.com 2023-03-31 03:14 出处:网络
Does anyone know how to fix this error? I am using jquery 1.6.2 XMLHttpRequest cannot load http://www.reddit.com/.xml. Origin null is

Does anyone know how to fix this error? I am using jquery 1.6.2

XMLHttpRequest cannot load http://www.reddit.com/.xml. Origin null is not allowed by Access-Control-Allow-Origin.

开发者_如何学C
$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "http://www.reddit.com/.xml",
        dataType: "xml",
        crossDomain: true,
        success: xmlParser
    });

    // ...
});


Use zrssfeed it'll make your life a lot easier, jsFiddle.

$('#test').rssfeed('http://www.reddit.com/.xml');


its because same-origin-policy create a server side proxy and have that proxy query the webservice and return your ajax request the xml response

0

精彩评论

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

关注公众号