`

ajax jquery submit form

阅读更多
Form插件,支持Ajax,支持Ajax文件上传,功能强大,基本满足日常应用

插件下载:jquery.form.js


1、Form插件的详细使用方法及应用实例

http://www.malsup.com/jquery/form/


2、form实例:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>无标题页</title>
    <script type="text/javascript" language="JavaScript" src="js/jquery-1.2.6.min.js"></script>
    <script type="text/javascript" language="JavaScript" src="js/jquery.form.js"></script>
    <script>
     // prepare the form when the DOM is ready
/*$(document).ready(function() {
     // bind form using ajaxForm
     $('#htmlForm').ajaxForm({
         // target identifies the element(s) to update with the server response
         target: '#htmlExampleTarget',

         // success identifies the function to invoke when the server response
         // has been received; here we apply a fade-in effect to the new content
         success: function() {
             $('#htmlExampleTarget').fadeIn('slow');
         }
     });
});
*/


// prepare the form when the DOM is ready
$(document).ready(function() {
     var options = {
         target:         '#htmlExampleTarget',    // target element(s) to be updated with server response
         beforeSubmit:   showRequest,   // pre-submit callback 表单提交前被调用的回调函数
         success:        showResponse   // post-submit callback   表单提交成功后被调用的回调函数

         // other available options:
         //url:        url          // override for form's 'action' attribute
         //type:       type         // 'get' or 'post', override for form's 'method' attribute
         //dataType:   null         // 'xml', 'script', or 'json' (expected server response type)
         //clearForm: true         // clear all form fields after successful submit
         //resetForm: true         // reset the form after successful submit

         // $.ajax options can be used here too, for example:
         //timeout:    3000
     };

     // bind to the form's submit event
     $('#htmlForm').submit(function() {
         // inside event callbacks 'this' is the DOM element so we first
         // wrap it in a jQuery object and then invoke ajaxSubmit
         $(this).ajaxSubmit(options);

         // !!! Important !!!
         // always return false to prevent standard browser submit and page navigation
         return false;
     });
});

// pre-submit callback
function showRequest(formData, jqForm, options) {
     // formData is an array; here we use $.param to convert it to a string to display it
     // but the form plugin does this for you automatically when it submits the data
     var queryString = $.param(formData);

     // jqForm is a jQuery object encapsulating the form element.   To access the
     // DOM element for the form do this:
     // var formElement = jqForm[0];

     alert('About to submit: \n\n' + queryString);

     // here we could return false to prevent the form from being submitted;
     // returning anything other than false will allow the form submit to continue
     return true;
}

// post-submit callback
function showResponse(responseText, statusText)   {
     // for normal html responses, the first argument to the success callback
     // is the XMLHttpRequest object's responseText property

     // if the ajaxSubmit method was passed an Options Object with the dataType
     // property set to 'xml' then the first argument to the success callback
     // is the XMLHttpRequest object's responseXML property

     // if the ajaxSubmit method was passed an Options Object with the dataType
     // property set to 'json' then the first argument to the success callback
     // is the json data object returned by the server

     alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
         '\n\nThe output div should have already been updated with the responseText.');
}

</script>
</head>
<body>
                <form id="htmlForm" autocomplete="on" method="post" action="r.aspx">
                            <TEXTAREA id=MyEnounce name=MyEnounce rows=5 cols=55></TEXTAREA>
                             <div id="htmlExampleTarget"></div>
                <input  type="submit" value="注 册" />
                </form>

</body>
</html>

提交的页面 r.aspx<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Text" %>
  
<%
     Response.Write(Request.Form["MyEnounce"]);

%>
分享到:
评论
1 楼 yelang2009 2011-02-16  
very good

相关推荐

    jquery.form.js完美ajax无刷新上传图片插件

    jquery.form.js,这是一个完美提交表单的jquery插件,jquery的ajax无法提交图片,而这个插件可以完美解决,使用方法,将该文件放到jquery后面引入:$('#order_form').ajaxForm(function(a) { var b = eval("(" + a ...

    jquery.form.js

    jquery.form.用语ajax提交表单,$("id").submit();可以直接用ajax提交表单,多用于上传图片

    jquery.form.js完美表单提交插件

    jquery.form.js,这是一个jquery插件,jquery的ajax无法提交图片,而这个插件可以完美解决,使用方法,将该文件放到jquery后面引入:$('#order_form').ajaxForm(function(a) { var b = eval("(" + a + ")"); alert...

    jquery.form.js实现将form提交转为ajax方式提交的方法

    主要介绍了jquery.form.js实现将form提交转为ajax方式提交的方法,涉及jQuery插件实现form表单的Ajax提交技巧,非常具有实用价值,需要的朋友可以参考下

    基于jQuery通过jQuery.form.js插件使用ajax提交form表单

    我简单使用了一下,jQuery Form插件有一下优点: 1.支持提交前验证. 2.支持提交后回调. 3.采用AJAX方式,有很好的用户体验 4.提交方式是灵活.只要指定要提交的form ID即可.想提交那个form.就可提交那个.同时提交...

    jqueryform.js

    // headers:{"ClientCallMode" : "ajax"},//添加请求头部 enctype="multipart/form-data" success: function(data){ if(data.msg=="success"){ alert&#40;"保存成功"&#41;; }else{ alert&#40;"保存失败"&#41;...

    jQuery.Form实现Ajax上传文件同时设置headers的方法

    废话不多说了,关于jquery form实现ajax上传文件的方法,大家参考一下实例代码吧: &lt;span xss=removed&gt;function ajaxSubmitForm() {&lt;/span&gt; var option = { url : cache.batchImport, type : 'POST', ...

    jquery-ajax-form-submit.zip_Do You

    Webmaster will activate your member account after checking your files. If you do not want to upload source code,

    jQuery使用ajaxSubmit()提交表单示例

    ajaxSubmit(obj)方法是jQuery的一个插件jquery.form.js里面的方法,所以使用此方法需要先引入这个插件。如下所示: 代码如下:[removed][removed][removed][removed] 那么,如何通过ajaxSubmit(obj)提交数据呢?首先...

    jquery ajax表单提交

    表单进行无刷新提交,ajax技术 if (!this.length) { log('ajaxSubmit: skipping submit process - no element selected'); return this; } var method, action, url, $form = this; if (typeof options == ...

    jQuery.form.js的使用详解

    面临问题:form表单submit之后,后端会返回提示信息。但原生html无法获取后端返回的数据,就造成了这样一种局面:提交之后,页面发生跳转,在一个空白页面上显示了后端返回的json数据,用户体验0分。 解决办法:使用...

    浅谈jquery.form.js的ajaxSubmit和ajaxForm的使用

    • 依赖的脚本文件 [removed][removed] [removed][removed] • ajaxSubmit 和ajaxForm区别...在document的ready函数中,使用ajaxForm来为AJAX提交表单进行准备。提交动作必须由submit开始 ajaxForm()适用于以表单提交

    Jquery Dynamic FormValidation:jQuery动态FormValidation插件-开源

    易于实施。 只需将class =“ required”设置为必填字段的属性,然后Submit Button将被动态激活/停用。 可以根据站点主题定制CSS。 这个带有Ajax的插件将很快更新。

    Ajax-Spring-MVC-CRUD-form-submit-and-ajax.zip

    Ajax-Spring-MVC-CRUD-form-submit-and-ajax.zip,spring mvc crud应用程序(springmvc、hibernate 4.x、bootstrap 3.x、jquery、mysql),ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json...

    jquery拼接ajax 的json和字符串拼接的方法

    整理文档,搜刮出一个jquery拼接ajax 的json和字符串拼接的代码,稍微整理精简一下做下分享。 jQuery拼接字符串ajax &lt;form id="myForm" action="#"&gt; &lt;input name="name"/&gt; &lt;input name="age"/&gt;...

    jquery实现ajax提交form表单的方法总结

    方法一: 代码如下:... { var AjaxURL= “../OrderManagement/AjaxModifyOrderService.aspx”; alert&#40;$(‘#formAddHandlingFee’&#41;.serialize()); $.ajax({ type: “POST”, dataType: “html”, 

    Jquery让form表单异步提交代码实现

    这篇文章主要介绍了Jquery让form表单异步提交代码实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1.监听表单提交事件,并阻止表单提交 $(form).submit...

    jQuery Form Plugin

    使用ajax提交一个html的form 用法: $('#myForm').ajaxSubmit(function(data) {alert('Form submit succeeded! Server returned: ' + data); }); 具体可以用记事本打开看英文说明

    解决jquery submit()提交表单提示:f[s] is not a function

    jquery submit()无法提交表单 报错:f[s] is not a function,很是疑惑搜集整理了一些解决方法,感兴趣的朋友可以了解下啊,希望本文对你有所帮助

Global site tag (gtag.js) - Google Analytics