Данные и данные о рядах - PullRequest
0 голосов
/ 01 мая 2018

PHP-код возвращает мою таблицу, но отлаживая JavaScript-код, я увидел, что он не выполняет function(data), поэтому он оставляет только класс «Добавление». Что не так с моим кодом? Как я могу это исправить?

function format(d) {
  var div = $('<div/>').addClass('loading').text('Loading...');

  var product_id = d['DT_RowId']; //This is the ItemId
  var btn_action = 'item_detail';

  $.ajax({
    url: 'item_action.php', //Calling the function
    type: "POST",
    data: {
      product_id: product_id,
      btn_action: btn_action //Set item_id and variable
    },
    dataType: 'json',
    success: function(data) { //If data is success it will write the html
      div.html(data.html).removeClass('loading');
    },
    error: function() {
      $('#item_data').html('Bummer: there was an error!');
    }
  });

  return div;
}
$data = array();
$data[] = '<table class="table table-bordered table-striped dataTable no-footer" cellpadding="5" cellspacing="0" border="0" style="padding-left: 50px">';               

foreach($result as $row) <!--Fill the table cells-->
{   
  $sub_array = array(); <!--Set the array to fill with datafields-->
  $sub_array[] = '<tr>';
  $sub_array[] = '<td>Price Code</td>';
  $sub_array[] = '<td>'.$row["pricecode_code"].'</td>';
  $sub_array[] = '</tr>';
  $data[] = $sub_array;
}   

$data[] = '</table>';   <!--Closing table-->
echo json_encode($data); <!--Return the table formatted-->
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...