我有一个使用 Jquery 和数据表插件从后端返回的数据表。我需要在数据表中选择订单号并提醒它。警报和控制台在数据表的第一页中运行良好,但不再从第二页触发。我用谷歌搜索但.live()
已弃用,建议的答案.on()
似乎不起作用。
查询:
$(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!");
}
});
});