开发者

Processing html form in background

I have the following code开发者_开发技巧 -

   <form id="smsform" class="appnitro"  method="post" action="/form" onSubmit="alert('Your message has been delivered.');">             
                <input type="hidden" value="<?php echo $message; ?>" name="message" />

and so on... Now what i want is that when the form is submitted then instead of going to the page /form the current window should remain at the same location and the page /form to be processed in the background.


you need submit via ajax call

example :

http://www.tizag.com/ajaxTutorial/ajaxform.php

if u want to use a jquery (js library)

look on :

http://www.georgetruong.com/2009/06/11/how-to-submit-a-form-with-ajax-in-jquery/


That should be done with AJAX. jQuery makes this easy; http://jquery.malsup.com/form/ provides a solution that virtually does it for you.


Remove the action parameter from the form. Change the submit button to a custom button with a javascript code that performs the background task. See http://www.javaworld.com/jw-06-1996/jw-06-javascript.html to use javascript with forms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜