结果进入控制台,但无法在循环内打印

时间:2018-12-21 06:17:19

标签: html ajax

可以在控制台中检索值,但在view中,其显示为undefined / [object,object]。也在for循环内,不能检索值。下面是我的代码。请建议我如何解决此问题以及我在哪里出错。

$.ajax({
  type: "POST",
  url: baseURL + "Unverified/processExcelForDownloaded",
  data: dataString,
  cache: false,
  success: function(data) {
    var res = JSON.parse(data);
    //alert(console.log(res));
    //$str = '<table id="example" class="table table-striped table-bordered display"><thead><tr><th>id</td><th>Name</th><th>Email</th><th>Phone</th><th>City</th><th>Event count</th><th>Action</th></tr></thead><tbody><tr><td>'+res.id+'</td><td>'+res.fname+' '+res.lname+'</td><td>'+res.email+'</td><td>'+res.countrycode+'-'+res.phone+'</td><td>'+res.city+'</td><td>'+res.paid_largeevent+'</td><td><button onclick="updatemethod('+organiserId+')" id="add" class="btn btn-success btn-bordered waves-effect waves-light data-toggle="tooltip" title="view">Add</button></td></tr></tbody></table>';
    $str = '<table id="example" class="table table-striped table-bordered display">' +
      '<thead>' +
      '<tr><th>Phone</th>' +
      '<th>Action</th>' +
      '</tr>' +
      '</thead>' +
      '<tbody>' +
      ' $.each(res, function(){' +
      '$.each(this,function(i,res){' +
      '<td>' + res.countrycode + '-' + res.phone + '</td>' +

      '</tbody>' +

      '</table>' +
      '});' +
      '});' +

      $("#event_details_table").show();
    $("#event_details_table .card-content").html($str);
  }
});

0 个答案:

没有答案