Page 1 of 1

Process information without refreshing the page?

Posted: Sun Jun 11, 2006 2:53 pm
by MonsieurRenard
Imagine a simple scenario in which the user enters any string into a textbox, presses submit, and the string is printed back out just below.

The only way I know how to do that right now is that the entire page refreshes, and sends the use back at the closest anchor, which is annoying.

Is there a way to get around that. I've been told something about DOM, will that do it? Are there any books on the matter?

Thank you very much for helping out a noobie, I plan on making an extended stay here since I will be working with PHP all summer :).

Posted: Sun Jun 11, 2006 3:03 pm
by alex.barylski
AJAX springs to mind :P

Posted: Sun Jun 11, 2006 3:05 pm
by MonsieurRenard
Ah yes, that went through my mind at one point.

Posted: Sun Jun 11, 2006 3:42 pm
by alex.barylski
Thats about the only way to perform the actions you require... 8)

Posted: Sun Jun 11, 2006 5:30 pm
by MonsieurRenard
I'll definetly look into it, thanks!

Re: Process information without refreshing the page?

Posted: Sun Jun 11, 2006 6:03 pm
by Christopher
MonsieurRenard wrote:Imagine a simple scenario in which the user enters any string into a textbox, presses submit, and the string is printed back out just below.
You don't need to do Ajax or to submit to a server to do that -- just Javascript. Call a function on the form submit event that sets the inner HTML of some element in your page with a value of a form field.

Posted: Sun Jun 11, 2006 11:12 pm
by MonsieurRenard
Maybe I used a bad example. Potentially I want to be able to have an interface with independent "objects" on the page, like in GMAIL, which uses AJAX.

Posted: Sun Jun 11, 2006 11:36 pm
by Christopher
Right, but much of what Gmail does is Javascript managing the presentation of the application. It occasionally makes calls back to the server -- as necessary.

Posted: Mon Jun 12, 2006 12:16 pm
by MonsieurRenard
Oh. :)

Thanks for this info, I think I'm going to need to reconsider how I'm going to make this work.

Posted: Mon Jun 12, 2006 12:32 pm
by GM
If you don't need anything too complex, javascript is best for this. If you actually need to fetch information back from the server depending on the user's choice, then you can't do this with simple javascript, you would need AJAX. If you are just taking information that has already been loaded to the page, or are adding database/server independent objects to the page, javascript will work just fine.

Posted: Mon Jun 12, 2006 12:47 pm
by Sathi
I found this tutorial made sense to me when nothing else did for an initial introduction

http://rajshekhar.net/blog/archives/85- ... orial.html