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'
        });


    }); 
Virendra
  • 2,560
  • 3
  • 23
  • 37
DEVOPS
  • 18,190
  • 34
  • 95
  • 118

2 Answers2

3

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

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

Community
  • 1
  • 1
linuxeasy
  • 6,269
  • 7
  • 33
  • 40
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.
alex
  • 479,566
  • 201
  • 878
  • 984