Ajax, detect logout redirection

Ajax, detect logout redirection

elgransanelgransan Posts: 3Questions: 0Answers: 0
edited October 2013 in General
When my app looses the session redirect to login, with DataTable ajax call that results in error response, I tried to trap the response and refresh the all page when this happend, but something I'm missing:

[code]
...
"fnServerData": function ( sSource, aoData, fnCallback ) {
$.ajax({
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": dataTableAjaxComplete
});
},
...

function dataTableAjaxComplete(data, textStatus, jqXHR) {
console.log(data);
if ( !data.iTotalRecords ) location.reload(); //expired
}
[/code]

I don't know how to if all ok exec the fnCallback(), or maybe I have to do it with another approach?

Thank you!!
This discussion has been closed.