Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Prompt/Response in StateChange

    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?

    Code:
    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);
    }

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Code:
                    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
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •