0
我想用這樣的事情在我的代碼,但沒有運氣...如何禁用基於Ajax響應AJAX提交按鈕
function captcha(data) {
var httpxml;
try {
// Firefox, Opera 8.0+, Safari
httpxml = new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
httpxml = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
httpxml = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
}
}
function stateck() {
if (httpxml.readyState == 4) {
document.getElementById("cap_error").innerHTML = httpxml.responseText;
var result = httpxml.responseText;
if (result == 'Error..try again') {
document.getElementById("regSubmit").disabled = true;
}
}
}
var url = "includes/captcha.php";
url = url + "?datacap=" + data;
url = url + "&sid=" + Math.random();
httpxml.onreadystatechange = stateck;
httpxml.open("GET", url, true);
httpxml.send(null);
}
編輯:
我的提交按鈕:
<input type="submit" value="Submit" id="regSubmit" name="Submit"/>
當ajax函數返回'Error..try again'時應該禁用regSubmit按鈕。但是這個功能現在不適合我。
if (result == 'Error..try again')
{
document.getElementById("regSubmit").disabled = true;
}
更詳細地解釋您希望腳本執行的操作。我不完全確定你的意思。 – Marius 2009-09-05 12:43:00