我对 Ajax 和花哨的盒子有一些愚蠢的问题。我是 Ajax 的新手。我在我的一个页面中使用花式框,就像花式框在单击按钮时所做的那样,它会弹出一个包含一些输入字段和按钮的表单。单击按钮时,尝试进行 ajax 调用,该调用需要显示指示器,直到调用完成。我进行了同步调用,但指示器没有显示,但是当我将其设为异步调用时,它正确显示. 谁能解释一下原因
更新:看看下面的代码......它工作正常并显示指标,直到我们从服务器得到响应......但是当点击花哨的框覆盖上的按钮时调用的函数不起作用异步 false isAsync 为 False
function LoadCarrier(isAsync)
{
try
{
SetCarrierLoadingIndicator("","Loading..");
xmlHTTPObject1 = GetXMLHTTPObject();
xmlHTTPObject1.onreadystatechange = OnPopulateCarrierComplete;
var currentTime = new Date();
var parameters = "";
var pageNumber=document.getElementById(hdnCarrierCurrentPage).value;
parameters += "CarrierPage";
parameters += "^" + pageNumber;
parameters += "~NetworkIds";
parameters += "^" + GetAllSelectedNetworks();
parameters += "~SelectedCarriers";
parameters += "^" + GetAllSelectedCarriers();
var parms = "?OPCode=LoadCarrier&Parms=" + parameters + "&RequestTime" + currentTime;
var ajaxURL = ajaxCallHandlerUrl + parms;
xmlHTTPObject1.open ("GET", ajaxURL, isAsync);
xmlHTTPObject1.send(null);
}
catch(exception)
{
alert(exception);
}
return false;
}
function OnPopulateCarrierComplete()
{
if (xmlHTTPObject1.readyState == 4)
{
var result = xmlHTTPObject1.responseText;
var contents = result.split("[6CE650P$0$NTS3E!]");
if (contents[0] == "SUCCESS")
{
SetCarrierLoadingIndicator("none","");
if(contents[1].length > 0)
{
var details=contents[1].split("[$sEpaRaToR$]");
document.getElementById(lblCarrier).innerHTML=details[0];
document.getElementById(lblCarrierPaging).innerHTML=details[1];
document.getElementById(lblCarrierCount).innerHTML=details[2];
var tmp=details[3].split(',');
for(var i=0;i<tmp.length;i++)
{
CarrierList.push(Number(tmp[i]));
}
}
else
{
document.getElementById(lblCarrier).innerHTML="";
document.getElementById(lblCarrierPaging).innerHTML="";
document.getElementById(lblCarrierCount).innerHTML="0";
}
}
else
{
if(contents[1] == "Session Expired")
{
parent.document.location = "Default.aspx";
}
else
{
alert(contents[1]);
}
}
}
}