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

Last Reply 7 months ago By zzz

Posted 7 months ago

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

You are viewing reply posted by: zzz 7 months ago.
I agree, here is the link: