Hi, i have created a XMLHttpRequest function, but it didn't work, this is my code
The program didn't run "CatchResul t()" function!(it only alert to "sent!")
I have also tried type "javascript:Cat chResult();", it also didn't alert "ran CatchResult function!"!
Any one have solution?
Thanks!
Code:
function CheckAccount (acc) {
CreateXMLHttpRequest();
if (ready == 1) {
if (!xmlHttp) {
alert('Please upgrade your browser');
}else{
var content = "AJAXQueryAccount=" + acc;
alert('set content!');
xmlHttp.onreadystatechange=CatchResult;
alert('set ors!');
xmlHttp.open("POST", "?a=r");
alert('opended!');
xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
alert('req. header set!');
xmlHttp.send(content);
alert('sent!');
}
}
}
function CatchResult() {
alert('ran CatchResult function!');
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
if(xmlHttp.responseText == '1') {
var x = document.getElementById('reg_remind_2');
x.style.position = 'absolute';
x.style.border = '#000 1px solid';
x.style.background = '#777';
x.style.marginBottom = '750px';
x.style.marginLeft = '375px';
x.style.width = '265px';
x.style.height = '15px';
x.style.zIndex = '100';
x.style.color = '#0F0';
x.style.textAlign = 'center';
x.innerHTML = 'Congratulation, this account is available!';
document.getElementById('reg_account').style.border = '1px #0F0 solid';
}else if(xmlHttp.responseText == '0') {
var x = document.getElementById('reg_remind_2');
document.getElementById('reg_account').style.border = '1px #F00 solid';
x.style.position = 'absolute';
x.style.border = '#000 1px solid';
x.style.background = '#777';
x.style.marginTop = '-390px';
x.style.marginLeft = '375px';
x.style.width = '265px';
x.style.height = '15px';
x.style.zIndex = '100';
x.style.color = '#F00';
x.style.textAlign = 'center';
x.innerHTML = 'Sorry, this account is unavailable!';
}
}
}
}
I have also tried type "javascript:Cat chResult();", it also didn't alert "ran CatchResult function!"!
Any one have solution?
Thanks!
Comment