3

Jquery と datatables プラグインを使用して、バックエンドから返されたデータテーブルがあります。データテーブルで注文番号を選択して警告する必要があります。アラートとコンソールは、データ テーブルの最初のページではうまく機能しますが、2 ページ目以降は起動しません。私はそれをグーグルで検索しました.live()が、非推奨であり、提案された回答.on()は機能しないようです。

Jクエリ:

$(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!");
    }
});

});

4

1 に答える 1