O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a jQuery .get() AJAX Request to Handle XML Data

$.get("getXMLData.php", myHandler); function myHandler(data){   var parks = $(data).find("park");   parks.each(function(){     var value = $(this).children("value").text();   } }

Using jQuery to get XML data from the server is a bit different from using JSON data. You still call the .get(url, handler(data)) method and pass in the url to the server location and specify a handler to handle the data. For example:

$.get("getXMLData.php", myHandler);

However, the XML data returned by the response will be a DOM object that is passed as the first argument to the handler function. The best way to handle the DOM object is to convert ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required