By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

retrive values from another PHP page using AJAX

vijcbe
P: 16
Hello friends!!
My program goes like this..
I have a page where user id and password are entered.
When they click submit button(input type is not submit), it goes to Javascript and sends AJAX request for another PHP page and checks whether those userid and password exists are not.

Javascript coding:

Expand|Select|Wrap|Line Numbers
  1. var url="abc.php";
  2. url=url+"?id="+str.username.value;
  3. url=url+"&pass="+str.password.value;
  4. url=url+"&sid="+Math.random();
  5. xmlHttp.onreadystatechange=stateChanged;
  6. xmlHttp.open("GET",url,true);
  7. xmlHttp.send(null);
  8.  
  9. document.forms[0].submit();
  10.  
Everything works perfect and I am getting the AJAX functions delivered on my main page. Since, i am submitting the form, it goes to the next page. Is there is any method available, so that, I can check whether the userid and password and submit the form only if the userid and password or correct. For example in gmail, if you give wrong id or password it will give an error message on the same page and gets submitted only when userid and password are correct.

Anyone please give me a fix for this issue.
Thanks a million in advance.
VJ
Oct 24 '07 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Put the submit in your stateChanged function. If the validation passes, submit the form, otherwise display the error message.
Oct 24 '07 #2

vijcbe
P: 16
Please tell me how to check for the condition in stateChanged function.
thanks,
VJ
Oct 24 '07 #3

acoder
Expert Mod 15k+
P: 16,027
That depends on what the PHP page returns when the validation passes/fails.
Oct 24 '07 #4

vijcbe
P: 16
Thank You Pal.. It works perfectly..
Again Thanks a million..
VJ
Oct 24 '07 #5

acoder
Expert Mod 15k+
P: 16,027
Again Thanks a million..
That's two million now :)

Glad to hear that you got it working.
Oct 24 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.