我有我這樣的代碼來獲取變量isItemLocked的值。從xmlhttp.responseText獲取一個布爾值
function authorItem(itemNumber){
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}else{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
url ="Some URL";
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
var isItemLocked = xmlhttp.responseText;
if(isItemLocked){
alert('Item has been Closed.Click OK to go to Search Page');
window.location = "SOME OTHER URL";
}else{
var url ="SOME OTHE URL 1";
location.href = url;
}
}
}
}
一個returnning布爾值true爲isItemLocked.But每次我去一些其他的解決方案URL.Any?
在'xmlhttp.responseText'返回什麼_exactly_?是一個字符串說'真/假'?一個號碼? – Oded 2010-11-11 13:06:42
這看起來不幸像W3School的競爭條件容易XHR代碼。你需要努力消除它的全局。 – Quentin 2010-11-11 13:10:14