I Ajax successives Anfragen bin mit und ich brauche einen Rückruf zu tun, wenn alle successives AnfragenDoppel Ajax-Request Antwort
function doAjaxRequest(data, id) {
// Get payment Token
return $.ajax({
type: "POST",
url: 'exemple1.php',
data: data
success: function(msg){
$.ajax({
type: "POST",
url: 'exemple2.php',
data: msg,
success: function(msgr) {
document.getElementById(id).value=msgr;
},
error:function (xhr, status, error) {
//Do something
}
});
},
error:function (xhr, status, error) {
//Do something
}
});
}
$.when(
doAjaxRequest(data, "input-1"),
doAjaxRequest(otherData, "input-2")
).done(function(a1, a2){
//Need do something when both second ajax requests (example2.php) are finished
}
Mit diesem Code fertig sind, ist die getan Funktionsaufruf, bevor meine Anrufe „exemple2. php "sind erfolgreich.
Wie kann ich darauf warten?
Danke für die Antwort!
Korrigieren Sie mich, wenn ich falsch liege, aber IE unterstützt es nicht, oder? –
https://api.jquery.com/category/deferred-object/ wird auf IE mit der gleichen Logik unterstützt. Danke! – Bouffe