Jump to content

storing ajax response in global variable


php_developer

Recommended Posts

I want to store the "xmlhttp.responseText" into a global variable so that the response i am getting can be used in another function. xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { validvar=xmlhttp.responseText; alert(validvar); a=validvar; } Actually I want to show the response in a confirm box and if the user click ok only then go to next page or submit the form else in case of cancel the form shuld not be submitted. here a is the global variable. I am storing the xmlhttp.responseText into validvar and then in global variable a. But The global variable remains empty when I access it another function. OR if there is any other way to store the response so that i can use it in another function and in the confirm box..

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...