当我在 IE 中运行以下代码时,它运行良好。
但在 mozilla ff 中,layerId 的值为空,因为reqGetSubMenuRef22.responseText
在 line1 处为空。
function ajaxFunctionCallGetSubMenuRef22(url)
{
if (window.XMLHttpRequest) { // Non-IE browsers and IE>=7
reqGetSubMenuRef22 = new XMLHttpRequest();
reqGetSubMenuRef22.onreadystatechange = processStateChangeGetSubMenuRef22;
try {
reqGetSubMenuRef22.open("GET", url, true);
(( reqGetSubMenuRef22.setRequestHeader && method == "GET" ) ? reqGetSubMenuRef22.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") : reqGetSubMenuRef22 );
} catch (e) {
alert(e);
}
reqGetSubMenuRef22.send(null);
}
else if (window.ActiveXObject) { // IE
reqGetSubMenuRef22 = new ActiveXObject("Microsoft.XMLHTTP");
if (reqGetSubMenuRef22) {
reqGetSubMenuRef22.onreadystatechange = processStateChangeGetSubMenuRef22;
reqGetSubMenuRef22.open("GET", url, true);
reqGetSubMenuRef22.send();
}
}
}
function processStateChangeGetSubMenuRef22()
{
if (reqGetSubMenuRef22.readyState == 4) { // Complete
if (reqGetSubMenuRef22.status == 200) { // OK response
var textToSplit = reqGetSubMenuRef22.responseText; //line1
if(textToSplit != null && textToSplit != '') {
subMenuRef = textToSplit;
}
else {
subMenuRef='';
}
layerId=subMenuRef;