O
O
Oleg Galimov2018-02-10 15:26:46
JavaScript
Oleg Galimov, 2018-02-10 15:26:46

Loop through multidimensional array in ajax loop to display?

Good time of the day.
Tell me how to iterate over a multidimensional array in the ajax loop to display on the screen?
I don't know what I'm doing right, I can't get it to display

success: function(data) {
  $.each(data, function(index,value) {
  index = index + 1;
  id = (value['id']);
  owner = (value['owner']);
  type_record = (value['type_record']);
  pri = (value['pri']);
  weight = (value['weight']);
  port = (value['port']);
  data = (value['data']);

how to display in a loop?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2018-02-10
@olegalimov

success: function(data) {
    var rowsHtml = '';

    $.each(data, function(index,value) {
        rowsHtml += '<tr>';
        rowsHtml += '    <td>' + value['id'] + '</td>';
        rowsHtml += '    <td>' + value['owner'] + '</td>';
        rowsHtml += '</tr>';
    }
    
    var html = '<table><thead><tr><td>Id</td><td>Owner</td></tr></thead><tbody>' + rowsHtml + '</tbody></table>';
    $(document).append(html);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question