I have a function that uses $.ajax. Within the success section, I have 3 function. The first one runs correctly. The second one contains another $.ajax call. The internal $.ajax call works correctly, but the third function in my initial $.ajax call doesn't run. Debugging the whole thing, it doesn't even reach the third function.
Here's a simplified version of the whole thing
function InitialFunction() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
data: myData,
url: myUrl,
async: false,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "MERGE");
},
success: function (data, textStatus, XmlHttpRequest) {
FirstFunction();
SecondFunction();
ThirdFunction(); // This is never reached
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
// Handle Errors
}
});
}
function FirstFunction(){
// Do stuff
}
function SecondFunction() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
datatype: "json",
data: myData,
url: myUrl,
async: false,
beforeSend: function (XMLHttpRequest) {
XMLHttpRequest.setRequestHeader("Accept", "application/json");
XMLHttpRequest.setRequestHeader("X-HTTP-Method", "MERGE");
},
success: function (data, textStatus, XmlHttpRequest) {
console.log("Stuff happened");
},
error: function (XmlHttpRequest, textStatus, errorThrown) {
// Handle Errors
}
});
}
function ThirdFunction() {
// Do more stuff
}
Thanks.