PHP and AJAX

Reply

Join Date: Nov 2004
Posts: 20
Reputation: codemaker is an unknown quantity at this point 
Solved Threads: 0
codemaker codemaker is offline Offline
Newbie Poster

PHP and AJAX

 
0
  #1
Jul 13th, 2009
I have an html page. when you click a button, an AJAX function will call a php page (like register.php). That page contains a form.
the URL is index.html and doesn't change to register.php because I called the PHP page through AJAX
Now that problem is: when I click the submit, I loose the html page and redirected to the register.php (the form handler is on the same page register.php).
I want the results and error messages to be displayed on the same page (index.html).

I hope the explanation was clear enough to be understood.
Thanks for the help
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 94
Reputation: sikka_varun is an unknown quantity at this point 
Solved Threads: 11
sikka_varun's Avatar
sikka_varun sikka_varun is offline Offline
Junior Poster in Training

Re: PHP and AJAX

 
0
  #2
Jul 13th, 2009
Hi...

Ok, i got your problem. Since you would have put action in your form tag as register.php, so this is bound to go to the register.php page. Instead you can do one thing:

Set the results/error messages in the SESSIONS variable. Now call index.html page and on body onload event, call another page through ajax that reads the session messages and displays them.

Check out if this helps.
VâRûN
---Happy to Help---
sikka_varun@yahoo.com
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 20
Reputation: codemaker is an unknown quantity at this point 
Solved Threads: 0
codemaker codemaker is offline Offline
Newbie Poster

Re: PHP and AJAX

 
0
  #3
Jul 13th, 2009
Thanks alot for the quick reply.
I was thinking of this solution but I had problems:-
1- Where should I put the code of handling the form, in the index.html page or in the register.php page?
2- If I put index.html in the action (action="index.html") and click the submit of the form, I loose the form and get only the index.html

I usually use SESSIONS when I want to pass variable between two pages or two scripts but in this case, how can I make the HTML and the PHP pages presist when I click the submit button?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 20
Reputation: codemaker is an unknown quantity at this point 
Solved Threads: 0
codemaker codemaker is offline Offline
Newbie Poster

Re: PHP and AJAX

 
0
  #4
Jul 13th, 2009
Hey guys
Any ideas?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 235 | Replies: 3
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC