Accessing settings.jqXHR in ajax.data function

Accessing settings.jqXHR in ajax.data function

TaloncorTaloncor Posts: 6Questions: 4Answers: 0

I stumbled upon a problem when trying to access settings.jqXHR in my ajax.data function and it is driving me crazy.
I just want to access the jqXHR object that should be in the settings object but if I try to access it, it is NULL. That wouldn't be so strange if console.log(settings) wouldn't clearly show that the settings object contains a jqXHR.object.

What am I missing?

[code]
$('#table').DataTable({
"ajax": {
"data": function(args, settings) {
console.log(settings); // -> Settings object containing a jqXHR-object
console.log(settings.jqXHR); // -> NULL
}
}
});
[/code]

Answers

  • allanallan Posts: 63,791Questions: 1Answers: 10,513 Site admin

    settings.jqXHR is set after the ajax.data function has been executed I'm afraid. Use preXhr if you need to access the raw jQuery object - however, I would suggest being very careful about using the settings object at all. It is considered to be private. It can, will and does change between versions.

    Allan

This discussion has been closed.