2
我有一個使用Jquery和datatables插件從後端返回的數據表。我需要選擇數據表中的訂單號並提醒它。警報和控制檯在數據表的第一頁中很好地工作,但不會從第二頁開始。我GOOGLE了它,但.live()
已棄用,建議的答案.on()
似乎不起作用。Alert()不會從數據表的第二頁觸發
的Jquery:
$(document).ready(function() {
$.ajax({
type: "POST",
//url: "OrderDetail.asmx/HelloWorld",
url: "Order.aspx/GetOrder",
data: "{'id':'273440'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$('#order').append(msg.d);
//alert(msg.d);
console.log(msg);
$('#orderTable').dataTable({
// "sScrollY": "100px",
"bAutoWidth": false,
"bDeferRender": true
//"bPaginate": false
});
// Click order number to get the details
// Problem is here
$('.orderNumber').on('click', function() {
var orderNum = $(this).text();
console.log(orderNum);
});
},
error: function (xhr, status, error) {
// Display a generic error for now.
alert("Ajax Error!");
}
});
});
什麼是你想怎麼辦? –
@ AhmedAlaaEl-Din我需要選擇數據表中的訂單號並提醒它。但它不會在數據表的第二頁中工作 – Quentin