Use jquery to insert multiple data into the implementation code of a modal box _jquery

Source: Internet
Author: User

Copy Code code as follows:

Bootstrap modal box (partial)
<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> name </td>
<td> Original Price </td>
</tr>
</table>
</div>

<div class= "Modal-footer" >
</div>
</div>
</div>

Copy Code code as follows:

/**
* View data details
* @ Black eyed poet <www.chenwei.ws>
*/
function OrderDetail (order_no)
{
1. Clear the Modal box data first
$ (' #orderDetail '). Find (' tr '). Nextall ().

2. External insertion
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 is as follows: [{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> ");
});
});
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.