[問題] ajax第二次讀取失敗?
第一次讀取數值的時候沒有問題,
但第二次讀取數值的時候(程式碼黃色字),回傳只有 \n
是哪邊邏輯有問題呢?
以下是我的部份程式,使用chrome:
情況,按一個button執行function checksum()
function checksum() {
//部份省略
cal(httpurl0);
}
function cal(url) {
createRequest(url);
}
var request = null;
var rdata="0";
var httpurl0 = "ShowMoney.jsp";
var httpurl1 = "SendMoney.jsp";
function createRequest(url) {
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxm12.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
if (request==null) {
alert('Giving up :( Cannot create an XMLHTTP instance');
}
request.open('POST',url,true);
request.onreadystatechange = updatePage;
request.send(null);
}
function updatePage() {
if (request.readyState == 4) {
if (request.status == 200){
rdata = request.responseText;
payprice.value=rdata;
alert('['+rdata+']');
if (totalprice.value <= rdata) {
setTimeout("cal("+httpurl0+")",5000)
}
else
cal(httpurl1+"?coco="+eval(rdata-totalprice.value));
}
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.134.178.246
※ 編輯: aaagang 來自: 220.134.178.246 (09/13 04:14)
→
09/13 08:32, , 1F
09/13 08:32, 1F
→
09/13 08:32, , 2F
09/13 08:32, 2F
→
09/13 08:33, , 3F
09/13 08:33, 3F
→
09/13 08:34, , 4F
09/13 08:34, 4F
→
09/13 08:34, , 5F
09/13 08:34, 5F