Problem with async stateLoadCallback
Problem with async stateLoadCallback
Hello Friends,
Please, I have big trouble with async stateLoadCallback.
When I use this call the script in section $(document).ready(function () stop correct work.
I mean this code for call
"stateLoadCallback" : function(settings, callback){
$.ajax({
url: 'helpari/db_state_load.php?listId=' + $('input[id=listId]').val()
, dataType: 'json'
, success: function (json) {
console.log(json);
callback(json);
}
, error: function () {
callback(null);
beginner = 1;
console.log("Not completed Load stateCallback")
}
});
},
And here is the code which is prepared in $(document).ready(function () section
$(document).ready(function () {
var DataTableBody = $('#dataTable tbody');
console.log(DataTableBody);
$('.leftmenutrigger').on('click', function (e) {
$('.side-nav').toggleClass("open");
e.preventDefault();
});
// prepare PDF view
DataTableBody.on('click', '#PDFMaker', function (){
var rsp, pathT;
var data = oTable.row($(this).parents('tr')).data();
var XMLFile = data['msg_link'];
var myData = "filename=" + XMLFile;
// Volame PDF maker
$.ajax({
type: "GET",
url: "helpari/show_pdf_new.php",
dataType: "text",
data: myData,
success: function (response) {
// alert(response);
rsp = response.split(":");
pathT = "helpari/" + rsp[1] + ".pdf";
opendialog(pathT, "PDF náhled");
},
error: function (xhr, ajaxOptions, thrownError) {
alert(thrownError);
}
});
});
So, but If I user the SYNC call as you can see in the another code, all works Okay, but in the Console I see the error message about synchonized XMLHttpRequest, that it is OLD in the main thread.
"stateLoadCallback" : function(settings, callback){
var o;
$.ajax({
url: 'helpari/db_state_load.php?listId=' + $('input[id=listId]').val()
, dataType: 'json'
, async: false
, success: function (json) {
o = json;
}
, error: function () {
callback(null);
beginner = 1;
console.log("Nepovedl se Load stateCallback")
}
});
return o;
},
Please, Where is the problem?
Why doesn't it work correctly with asynchronous call of the loadStateCallback?
Thanks a lot for help
Honza H
Answers
Hi @harvy76 ,
There's a lot going on there. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin