0

在通过 ajax 请求刷新/重新加载 jquery 数据表后,当我尝试在警报框中查看任何单元格数据时,它会给出多个但相同的警报,在每次重新加载警报数增加后,它看起来也为之前的 ajax 请求获得了价值。有什么解决办法吗?

         function reload(){ 
               $.ajax({
                type: "POST",                   
                url: "../WebServices/HortalDay.aspx/GetHartalDay",
                contentType: 'application/json; charset=utf-8',
                dataType: "json",
                success: function (d) {                     
                    var jObject = eval('(' + d.d + ');');                      
                    var input = {
                        "aaData": jObject,
                        "aoColumns": [{ "sTitle": "Hartal Date", "mData": "HartalDate", "sWidth": "20%" },
                            { "sTitle": "Note", "mData": "Note" },
                            { "sTitle": "Status", "mData": "Status" },

                        ],
                        "aLengthMenu": [[10, 25, 50], [10, 25, 50]],
                        "iDisplayLength": 25,
                        "bProcessing": true,
                        "bJQueryUI": true,
                        "bPaginate": true,
                        "bdestroy": true,
                        "cache": false,
                        "aoColumnDefs": [
                            { "aTargets": [0],

                                "sType": 'date',
                                "fnRender": function(oObj) {
                                    var javascriptDate = parseDate((oObj.aData["HartalDate"]));
                                    return javascriptDate;
                                }
                            }
                        ]
                    };

                }})
 $("#datatable").dataTable(input);

};

$("#btnShow").click(function(){
          reload();
var date = $('#datatable tr').filter(".row_selected").find('td:eq(0)').text());
          alert(date); 
                 });
4

1 回答 1

0

Got the Answer. Just I had to set the windows location -

  $("#btnShow").click(function(){
      window.location = "../SetupUI/HortalDaySetup.aspx";
      reload();
      var date = $('#datatable tr').filter(".row_selected").find('td:eq(0)').text());
      alert(date); 
             }); 

You may find the logical explanation in this link- C# webservice calls using jQuery 1.7.1 /eval/seq/

于 2013-10-09T04:34:10.957 回答