abort previous ajax call in datatables 1.10
abort previous ajax call in datatables 1.10
datatraders
Posts: 7Questions: 0Answers: 0
Hi there,
my previous implementation of the function doing the ajax call is not working in datatables 1.10 to abort the previous ajax call:
[code]// Aborting the previous XHR;
if (settings.jqXHR)
settings.jqXHR.abort();
settings.jqXHR = $.ajax({ ... }[/code]
how can I get the expected behavior back?
best regards - Jens
my previous implementation of the function doing the ajax call is not working in datatables 1.10 to abort the previous ajax call:
[code]// Aborting the previous XHR;
if (settings.jqXHR)
settings.jqXHR.abort();
settings.jqXHR = $.ajax({ ... }[/code]
how can I get the expected behavior back?
best regards - Jens
This discussion has been closed.
Replies
[code]settings.jqXHR[/code]
now with
[code]settings.nTable.jqXHR[/code]
That seems to work.
Allan
[code]function (data, callback, settings) {
//data manipulation here ...
// ...
// Aborting the previous XHR;
if (settings.nTable.jqXHR)
settings.nTable.jqXHR.abort();
settings.nTable.jqXHR = $.ajax({
"url": "/",
"data": data,
"success": function (json) {
$(settings.oInstance).trigger('xhr', settings);
callback( json );
},
"dataType": "json",
"cache": false,
"type": "post",
"error": function (xhr, error, thrown) {
xCore.systemError("", xhr, error);
return false;
}
});
}
[/code]
Why are you assigning the `jqXHR` object to `nTable` ?
This is where DataTables does its assignment of `jqXHR` : https://github.com/DataTables/DataTablesSrc/blob/master/js/core/core.ajax.js#L95 . So for fnServerData you would need to assign it yourself. If you are using the new `ajax` option, return the XHR object from your function.
Allan
okay..thanks. now it works.