Tutorial :Parsing through XML returned by web service with jQuery



Question:

I'm trying to parse an XML file returned by a webservice with jQuery. Here is the code I have set up, but nothing seems to happen.

$.ajax({      type: 'GET',      url: 'http://www.sample.com/webservice',      dataType: 'xml',      success: function(xml){          console.log(xml);          $(xml).find('movies').each(function(){              $(this).find('movie').each(function(){                  var lat = $(this).attr('lat');                  $('div#lat-info').html('<p>' + lat + '</p>');                         });          });      }  });  

The webservice does not explicitly create a file with '.xml' at the end that I can reference. I must reference the URL to the webservice.


Solution:1

You can't request XML cross-domain. It's a security issue.

To quote from http://answers.yahoo.com/question/index?qid=20080904014758AAyishS

"If you have access to server-side scripting, you can attempt to do a file-read of the remote file, and process it locally... which, however, depending on your host may have been disabled, as it lends itself for abuse."


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »