Page 1 of 1

Form submission without redirect?

Posted: Wed Nov 08, 2006 12:54 am
by JAB Creations
I would like to have users submit a form without a redirect. I can only guess AJAX would be the way to go and if so how would I go about it?

Posted: Wed Nov 08, 2006 1:25 am
by Luke
What do you mean "without a redirect"? Do you mean without a refresh? If so, than yes, AJAX is the way to go. If you're just looking to post to the same page you're on, just do this

(let's say the page you are posting from is called "index.php"...

Code: Select all

<form method="post" action="index.php">
Or this

Code: Select all

<form method="post" action="#">

Re: Form submission without redirect?

Posted: Wed Nov 08, 2006 1:48 am
by jmut
JAB Creations wrote:I would like to have users submit a form without a redirect. I can only guess AJAX would be the way to go and if so how would I go about it?
it is all about the workflow of you application. if you think it over you will see in most cases no redirect is necessary.
basically it goes to...

Code: Select all

//1.first process submitted data...if any.

//2.get data to fillin form (data will be updated...if processing submitted data ..or just default values...when you first see the form).

//3.display page.

Posted: Wed Nov 08, 2006 3:44 am
by Chris Corbyn
You can use images if you're uncomfortable with AJAX. You'll need AJAX if you want feedback from the server however.

The idea behind using images is to simply create a new Image() object and set it's src property to a URL containing GET vars. AJAX can do POST though.

Posted: Wed Nov 08, 2006 5:40 am
by JAB Creations
For clarification I want to exactly what a form does by default except to not redirect/reload.

I know the action attribute is required by various standards. I must keep this attribute and some valid value however I am curious if I can still submit the form and avoid AJAX altogether by stopping the redirect/reload?

If we can not then I suppose we should turn to AJAX then. I don't particularly care how it is executed except that it needs to be standards compliant and work with the application/xhtml+xml mime which most code does work with anyway. I only got as far as trying to use JavaScript to return false as the value of the action.

Posted: Wed Nov 08, 2006 6:29 am
by Chris Corbyn
JAB Creations wrote:For clarification I want to exactly what a form does by default except to not redirect/reload.

I know the action attribute is required by various standards. I must keep this attribute and some valid value however I am curious if I can still submit the form and avoid AJAX altogether by stopping the redirect/reload?

If we can not then I suppose we should turn to AJAX then. I don't particularly care how it is executed except that it needs to be standards compliant and work with the application/xhtml+xml mime which most code does work with anyway. I only got as far as trying to use JavaScript to return false as the value of the action.
I'm pretty sure IE tries to download application/xhtml+xml :)

To be to the point, you need AJAX for what you're trying to do. That's it.

Posted: Wed Nov 08, 2006 11:29 am
by JAB Creations
I know about IE and deal with it serverside. :evil: :wink: