我有以下名为Submit()的事件但是目前这个事件只进行了1次AJAX POST调用,我是否可以在单个事件中第一次调用成功时创建多个AJAX?
function Submit() {
if (isValidSubmit()) {
var input = BuildInputXML();
var svc = parent.svc;
var uid = parent.uid();
var ajax_url = svc + "/DR_DRStep7.svc/InsertSpdDist";
$.ajax({
type: "POST",
url: ajax_url,
data: "{\"input\": \"" + input + "\", \"planner\": \"" + parent.userID + "\"}",
contentType: "application/json; charset=utf-8",
dataType: "json",
processdata: true,
async: false,
success: function (data) {
if (data.InsertSpdDistResult) {
alert("Spd Distribution Data Saved!");
$("#cmdSubmit").attr('disabled', true);
displaySummary();
// Call another function that makes an AJAX call
GetUpdatedData();
} else {
alert('Failed to Insert Spd Distribution for data: ' + parent.data);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//alert(errorThrown);
}
});
}
}
答案 0 :(得分:0)
$.ajax({
type: "POST",
url: ajax_url,
data: "{\"input\": \"" + input + "\", \"planner\": \"" + parent.userID + "\"}",
contentType: "application/json; charset=utf-8",
dataType: "json",
processdata: true,
async: false,
success: function (data) {
if (data.InsertSpdDistResult) {
alert("Spd Distribution Data Saved!");
$("#cmdSubmit").attr('disabled', true);
displaySummary();
} else {
alert('Failed to Insert Spd Distribution for data: ' + parent.data);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//alert(errorThrown);
}
});
尝试将这段代码放入for或while循环