PDA

View Full Version : Prompt/Response in StateChange


psyborg01
04-18-2009, 11:05 PM
What I'm trying to do is get a prompt when OBJ is null and there is a response from the server. The problem is that even when there is a response, the prompt doesn't work, and the response is not shown. I made sure there was a response, making the page echo. Is the state change too fast?

function AjaxRequest(OBJ,URL,ARG)
{
XMLHttp=GetXMLHttp();
if(XMLHttp==false){
alert('Ajax object failed to initialize!');
end();
}
XMLHttp.open('GET',URL+ARG,true);
XMLHttp.onreadystatechange=function() {
if(XMLHttp.readyState==4){
document.getElementById('wobj').innerHTML='Loaded.';
if(OBJ)
{
OBJ.innerHTML=XMLHttp.responseText;
} else {
alert('Error :'+XMLHttp.responseText);
}
if(XMLHttp.status!=200)
{
alert('AJAX Error: Document Not Found.');
}
} else {
document.getElementById('wobj').innerHTML='Loading...';
}
}
XMLHttp.send(null);
}

A1ien51
04-20-2009, 03:03 PM
if(XMLHttp.readyState==4){
if(XMLHttp.status==200){
document.getElementById('wobj').innerHTML='Loaded.';
if(OBJ != null){
OBJ.innerHTML=XMLHttp.responseText;
} else {
alert('Error :'+XMLHttp.responseText);
}
}
else{
alert('AJAX Error: Document Not Found.\n' + XMLHttp.status + " \n " + XMLHttp.statusText);
}
}


Eric