How to get the Table Header when webmethod returning XML string using Ajax jQuery

Last Reply on Nov 16, 2016 08:21 PM By zzz

Posted on Nov 16, 2016 02:12 AM

I would like to know how to get the table header of the return data in below code using JQUERY

public static string GetCustomers(string searchTerm, int pageIndex)
    string query = "[GetCustomers_Pager]";
    SqlCommand cmd = new SqlCommand(query);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@SearchTerm", searchTerm);
    cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
    cmd.Parameters.AddWithValue("@PageSize", PageSize);
    cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4).Direction = ParameterDirection.Output;
    return GetData(cmd, pageIndex).GetXml();

So if going to get the data in jquery, it used

function OnSuccess(response) {
        var xmlDoc = $.parseXML(response.d);
        var xml = $(xmlDoc);
        var customers = xml.find("Customers");
        if (row == null) {
            row = $("[id*=gvCustomers] tr:last-child").clone(true);
        $("[id*=gvCustomers] tr").not($("[id*=gvCustomers] tr:first-child")).remove();
            $.each(customers, function () {
                var customer = $(this);
                $("td", row).eq(0).html($(this).find("ContactName").text());
                $("td", row).eq(1).html($(this).find("CustomerID").text());
                $("td", row).eq(2).html($(this).find("City").text());
                row = $("[id*=gvCustomers] tr:last-child").clone(true);



So what I would like to know is how to get the Table Header of the return data. Thanks