I am using ajax replay and during ajax call I want to update the X-CSRF-TOKEN value but I am not able to change the X-CSRF-TOKEN sending old value.
$.ajax({
url: url,
type: requestType,
contentType: contentType,
data: data,
beforeSend: function(jqXHR, settings) {
if (typeof beforeSendCallbackFunction === "function") {
beforeSendCallbackFunction();
}
},
success: function(response, textStatus, jqXHR) {
if(typeof JSON.parse(response) =='object'){
var value = JSON.parse(response);
if('_token' in value) {
if(value._token != 'logout') {
$.ajaxSetup({
headers: {
"X-CSRF-TOKEN": value._token
},
async: false
});
$.ajax(this);
}
}
}
}
});