Form submission without redirect?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Form submission without redirect?

Post 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?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post 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="#">
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: Form submission without redirect?

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

I know about IE and deal with it serverside. :evil: :wink:
Post Reply