0

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.

$(document).ready(function () {
    $.ajax({
        type: "GET",
        url: "http://www.reddit.com/.xml",
        dataType: "xml",
        crossDomain: true,
        success: xmlParser
    });

    // ...
});
4
  • Short answer is that crossDomain doesn't work out of the box with xml, but it does work with JSONP. Getting it to work with XML requires some additional work. Commented Aug 25, 2011 at 6:28
  • possible duplicate of Need Help With Getting Cross Domain XML With JavaScript Commented Aug 25, 2011 at 6:32
  • Hi, I agree with Ray, see the following webpage for more detailed info: nczonline.net/blog/2010/05/25/… Regards Commented Aug 25, 2011 at 6:38
  • I guess I can use the json version of the reddit api Commented Aug 25, 2011 at 6:39

2 Answers 2

1

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

$('#test').rssfeed('http://www.reddit.com/.xml');
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.