0

I need to parse a xml file using jQuery from an external domain. How can I do that?

This is my code.

$("#mydiv").click(function () {


        $.ajax({
            url: 'http://tester.com/testxml/announcement.xml',
            success: function(data){
                alert( $(data).find('Document:title').text() );
            },
            dataType: 'xml'
        });


    }); 
3
  • Is your domain name listed in the crossdomainpolicy.xml file of targeted domain? Commented Dec 27, 2011 at 7:13
  • this may help you stackoverflow.com/questions/1201429/… Commented Dec 27, 2011 at 7:15
  • Do you have access to the code of the second domain? Commented Dec 27, 2011 at 7:16

2 Answers 2

3

You cannot read cross-domain xml using Jquery.ajax().

However, you could try for script-inclusion which works cross-domain

Sign up to request clarification or add additional context in comments.

Comments

1

You could...

  • Use a server side proxy.
  • Use YQL.
  • If you can access the code of the second server and don't need to support IE7 and below, set up CORS.

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.