Friday, November 2, 2012

jQuery Get XML Response Example

The jQuery Get() ajax method supports HTML, XML, JSON and Text type responses sent by the server. In this post we shall see on how to process XML data returned from the server using the jQuery Get() method.

The syntax for receiving and processing XML response is as follows.

$.get("<Server URL>", successHandlerFunction(…));

The following example receives a XML format data from the server and displays the data in a DIV tag in the browser.

.aspx Page (Client Side)
<html xmlns="" >
<head runat="server">
    <title>jQuery Ajax Load</title>
    <script type="text/javascript" src="JavaScript/jquery-1.7.2.js"></script>
        $(document).ready(function() {
            // Get XML Response data from the Server
            $('#btnGetXML').click(function(event) {
                var nameList = "";
                $.get("AjaxData.xml", function(result) {
                    $(result).find("Name").each(function() {
                        nameList = nameList + $(this).text() + "<br />";
    <form id="frmAjax" runat="server">
    <table border="1">
            <tr valign="middle">
                        Text="Get XML" />
                <td align="center">
                    <br /><div id="divXML"></div> 

.AjaxData.xml (Server Side)

<?xml version="1.0" encoding="utf-8" ?>
      <Address>125. E.Spring Creeks, OH</Address>
      <Address>121 Highway, Plano TX</Address>

Related Post
jQuery Get Method
jQuery Get HTML Response Example
jQuery Get XML Response Example
jQuery Get Text Response Example
jQuery Get JSON Response Example
jQuery HTTP GET Request Example

Search Flipkart Products:

No comments: