Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
How can I submit a form without having the page change?
Old 08-10-2011, 10:45 PM How can I submit a form without having the page change?
Super Talker

Posts: 113
Trades: 0
I need a form to be submitted without the page actually changing. I don't know much about javascript/ajax/jquery, but is there a way for a form to be submitted without the page changing? For instance, maybe when the user clicks the submit button some javascript code could make an HTTP GET or POST request to a PHP file that then acts on the information?

Anyone have any idea how this can be done easily?
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-11-2011, 03:52 AM Re: How can I submit a form without having the page change?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
I need a form to be submitted without the page actually changing.
Explain a little more, what do you mean by "without the page actually changing"?

Do you mean without the URL changing?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-11-2011, 04:16 AM Re: How can I submit a form without having the page change?
Novice Talker

Posts: 12
Name: Teodorescu Mihail
Location: Romania
Trades: 0
Yes, you can do with ajax with JQuery
look my example : jsfiddle.net/Sonic3R/9fzuJ/1/
at bottom of Javascript section, you'll find a PHP example, how it works with Ajax

Documentation : api.jquery.com/jQuery.ajax/


PS: @chrishirst-> I guess he refers to backend script, without reloading page
Sonic3R is offline
Reply With Quote
View Public Profile
 
Old 08-11-2011, 04:50 AM Re: How can I submit a form without having the page change?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Sonic3R View Post

PS: @chrishirst-> I guess he refers to backend script, without reloading page
Ah well! I've been programming for long enough to know that guessing is rarely the best choice when developing a code solution.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-11-2011, 05:14 AM Re: How can I submit a form without having the page change?
Novice Talker

Posts: 12
Name: Teodorescu Mihail
Location: Romania
Trades: 0
Ok chris, I don't guess anymore , I'm sure what he wants :P. Are you happy now or have you something against me ? Every post where I did, you are against me ... every time.
Sonic3R is offline
Reply With Quote
View Public Profile
 
Old 08-11-2011, 08:25 AM Re: How can I submit a form without having the page change?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It's nothing personal. EVERYBODY gets the same treatment regardless. There is more than enough mis-information around already, I simply try to redress the balance slightly whenever possible.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-11-2011, 09:40 AM Re: How can I submit a form without having the page change?
Super Talker

Posts: 113
Trades: 0
Sonic3R - Thanks for your help. I'll try understanding the code you posted.

Quote:
Originally Posted by chrishirst View Post
Explain a little more, what do you mean by "without the page actually changing"?

Do you mean without the URL changing?
Normally when a form is submitted, the page changes or reloads, and I don't want the page to change. I.E. When someone clicks the submit button, perhaps a little message saying "thanks for submitting" pops up below the form, but that's it; the page doesn't change.
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
Old 08-11-2011, 03:16 PM Re: How can I submit a form without having the page change?
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Quote:
Originally Posted by Learnin' n00b View Post
Sonic3R - Thanks for your help. I'll try understanding the code you posted.



Normally when a form is submitted, the page changes or reloads, and I don't want the page to change. I.E. When someone clicks the submit button, perhaps a little message saying "thanks for submitting" pops up below the form, but that's it; the page doesn't change.
Then yes..
Jquery is quite handy..

You still need to have the submit page ( the page you call to actually do teh leg work )

However in this case when someone clicks submit.
Jquery/ajax/whatever will get the form data and send it to your page in the background.
It would then do something like. document.write"done"; etc..

http://api.jquery.com/submit/
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 08-15-2011, 04:24 AM Re: How can I submit a form without having the page change?
miki86's Avatar
Extreme Talker

Posts: 184
Location: print_r($serbia);
Trades: 0
Mootools can also do the job just the same.

You can use several methods, i preferr Request HTML because you can return nice formated html from php proccessing page:

http://mootools.net/docs/core/Request/Request.HTML

This can be also useful to you, form validation class, which is just a make up so it looks better.

http://mootools.net/docs/more/Forms/Form.Validator

Last edited by miki86; 08-15-2011 at 04:27 AM..
miki86 is online now
Reply With Quote
View Public Profile
 
Reply     « Reply to How can I submit a form without having the page change?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33699 seconds with 12 queries