Here I have one requirement with AJAX and I gave one url(UpdateURL) to the url param. In success case I'm going to call one dataTable(called loadGrid()),
here I need to call same url(UpdateURL) to the loadGrid(), meanwhile I'm calling two times same url(UpdateURL), it causes duplicate requests.
Can any one help me how to use url(UpdateURL) single time and avoiding duplicate requests. Sorry for the confusion.
Here is my code,
$("#UploadButton").click(function(){
$("#idLoading").show();
var UpdateURL="some url";
$.ajax({
type: "post",
url: UpdateURL, // calling first time
dataType: "json",
cache : false,
success: function(response) {
loadGrid(UpdateURL); // calling second time
$("#idLoading").hide();
},
error: function (xhr, status) {
$("#idLoading").show();
timeout_trigger();
}
});
});
function loadGrid(url){
$.getJSON(url,function (output)
{
try
{
var pdlJsonObj = output.aaData;
var tdata = $("#IdDatatble").dataTable({
"aaData": pdlJsonObj,
"bDestroy": true,
"sPaginationType": "full_numbers",
"aaSorting": [],
"fnCreatedRow": function (nRow, aData, iDisplayIndex, iDisplayIndexFull)
{
$(nRow).attr('id', iDisplayIndex);
},
"fnInitComplete": function ()
{
$("#IdDatatble tbody tr:eq(0)").find('td').each(function () { });
}
});
}
catch(err)
{
alert(err.message);
}
});
}