Ajax onload problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   zenith_wolf
Posted On:   Monday, August 27, 2007 03:29 PM

      alert(getVal);       document.getElementById("myForm1").innerHTML=getVal;   } ]]> hey, I am trying to get ajax to get values from a jsp page when the html loads, but first time the page loads, it gives me an error saying "The data necessary to complete this operation is not yet available" for the xmlHTTPRequest.responseText but when i refresh the page, it loads perfectly! jsp tested and works so the problem resides in my ajax/html file. heres the html:    More>>

      alert(getVal);

      document.getElementById("myForm1").innerHTML=getVal;

  }



]]>

hey,
I am trying to get ajax to get values from a jsp page when the html loads, but first time the page loads, it gives me an error saying "The data necessary to complete this operation is not yet available" for the xmlHTTPRequest.responseText but when i refresh the page, it loads perfectly! jsp tested and works so the problem resides in my ajax/html file.


heres the html:





































   <<Less

Re: Ajax onload problem

Posted By:   Axel_Richter  
Posted On:   Tuesday, August 28, 2007 07:15 AM

Hi,



if you call
xmlHttp.open("GET", url,true);
with the third parameter true, then the request is asynchronous. The execution of the JavaScript function will continue while the response of the server has not yet arrived. You have to use a callback funktion in
xmlHttp.onreadystatechange
to handle the response. Look at http://developer.mozilla.org/en/docs/AJAX:Getting_Started.



greetings



Axel
About | Sitemap | Contact