locked
how to add heading for json data in ajax jquery RRS feed

  • Question

  • User-1722422105 posted

    Hi all 

    I am geting the data from 

    function loadData() {
    $.ajax({
    url: "/Home/List",

    type: "GET",
    contentType: "application/json;charset=utf-8",

    dataType: "json",
    success: function (result) {
    var html = '';
    var hhi=' " ';
    $.each(result, function (key, item) {


    var hh = item.imag_path1+hhi;
    html += '<tr>';
    html += '<td>' + item.empid + '</td>';
    html += '<td>' + item.Name + '</td>';
    html += '<td>' + item.Age + '</td>';
    // im

    I want to add the column name(heading) when I display 

    how to do this

    Tuesday, June 26, 2018 9:12 AM

All replies

  • User-492460945 posted

    Hi sidu,

    You can append related HTML to your variable before assigning dynamic row values as below

    html = <tr><td>Employee ID</td><td>Name</td><td>Age</td></tr>

    Thanks,

    RajeshV.

    Tuesday, June 26, 2018 10:02 AM
  • User-1171043462 posted

    change

    var html = '';

    to

    var html = '<tr><th>Employee Id</th><th>Name</th><th>Age</th></tr>';

    Tuesday, June 26, 2018 2:09 PM