请参阅以下代码:
function GetSQLTable() {
var str = $("#<%=fieldGroupReferences.ClientID%>")[0].value
var res = str.split(",");
var numSucceeded = 0;
$("#LoadingImage").show();
$("#LoadingImage2").show();
for (var i = 0; i < res.length; i++) {
var div = document.createElement('div');
div.id = "div" + i
document.getElementById('info_div').appendChild(div);
var PossiblesPage = false;
$.ajax({
type: "POST",
url: "PrimaryNominalAjax.aspx/GetSQLTable",
data: '{username: "' + $("#<%=fieldUserName.ClientID%>")[0].value + '", terminalname: "' + $("#<%=fieldTerminalName.ClientID%>")[0].value + '", terminalip: "' + $("#<%=fieldTerminalIP.ClientID%>")[0].value + '", mappingid: "' + res[i] + '", usergroup: "' + $("#<%=fieldUserGroup.ClientID%>")[0].value + '", usn: "' + $("#<%=fieldUSN.ClientID%>")[0].value + '", requester: "' + $("#<%=fieldRequester.ClientID%>")[0].value + '", reason: "' + $("#<%=fieldReason.ClientID%>")[0].value + '", rrd: "' + $("#<%=fieldRRD.ClientID%>")[0].value + '", review: "' + $("#<%=fieldReview.ClientID%>")[0].value + '", possibles: "' + PossiblesPage + '",linkno: "", urn1: "", urn2: ""}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess(i, res.length),
failure: function (response) {
alert('there was an error loading the webpage')
}
});
}
function OnSuccess(i, totalrows) {
return function (response) {
alert(response.d)
}}
Ajax多次运行。我想在运行e.g. mappingID + " is currently running"
之前将映射ID打印到屏幕。在AJAX请求期间,MappingID被传递给服务器。是否有一个事件可以让我处理这个要求?我看过这里:http://api.jquery.com/Ajax_Events/。请问BeforeSend处理它吗?也就是说,BeforeSend总是在AJAX请求之前立即运行,即我现在希望这种情况发生:
Before Send MappingID 1
Before Send MappingID 2
Send MappingID 1
Send MappingID 2