Home  >  Article  >  Web Front-end  >  jQuery sample code for inserting multiple pieces of data into a modal box_jquery

jQuery sample code for inserting multiple pieces of data into a modal box_jquery

WBOY
WBOYOriginal
2016-05-16 16:35:231135browse
//Bootstrap模态框(局部)
<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>名 称</td>
      <td>原 价</td>
            </tr>
</table>
</div>

<div class="modal-footer">
</div>
</div>
</div>
/**
* 查看数据详情
* @黑眼诗人 <www.chenwei.ws>
*/
function orderDetail(order_no)
{
//1.先清空模态框数据
$('#orderDetail').find('tr').first().nextAll().remove();

  //2.外部插入
var order_no = order_no;

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

     //数据的格式如: [{no:123,old:abc},{no:234,old:def},{no:345,old:ghi}]
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>");
});
});
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn