Using jQuery to insert multiple data into the modal box implementation code

  • 2020-03-30 04:06:16
  • OfStack


//Bootstrap modal frame (local)
<div class="modal fade" id="orderDetail">
<div class="modal-dialog">
<div class="modal-content">
  <div class="modal-header">
</div> <div class="modal-body">
<table class="table">
<tr>
      <td> The name According to </td>
      <td> The original price </td>
            </tr>
</table>
</div> <div class="modal-footer">
</div>
</div>
</div>


/**
* View data details
* @ Black eye poet <www.chenwei.ws>
*/
function orderDetail(order_no)
{
//1. First, clear the modal box data
$('#orderDetail').find('tr').first().nextAll().remove();

  //2. Insert
externally var order_no = order_no;

$.post(base_url + '?d=admin&c=orders&m=ajax_order_detail', {order_no:order_no}, function(data){

     //The format of the data such as: [{no: 123, old: ABC}, {no: 234, old: def}, {no: 345, old: ghi}] < br / > var obj = eval('(' + data + ')');

$.each(obj, function(i, n){

var tr = $('#orderDetail').find('tr').last(); tr.after("<tr><td>"+ n['organize_name'] + " : " + n['cate_name'] + " -- " + n['course_name'] +"</td><td>"+ n['old_price'] +"</td><td>" + n['sale_price'] + "</td></tr>");
});
});
}


Related articles: