jQuery异步提交form表单
使用jquery.form.js官网现在地址表单插件来实现异步form表单提交。
先看看官方的介绍:
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are mutually exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example, $(document).ready(function() {
$('#myForm').on('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
}); Use ajaxForm when you want the plugin to manage all the event binding
for you. For example, $(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
}); You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
form does not have to exist when you invoke ajaxForm: $('#myForm').ajaxForm({
delegation: true,
target: '#output'
}); When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
实际使用中的方式:
<script type="text/javascript">
$(document).ready(function () {
$("#btnAjaxSubmit").click(function () {
var options = {
url: 'action.url',
type: 'post',
dataType: 'text',
data: $("#form").serialize(), //序列化
success: function (data) { //提交成功之后的回调函数
if (data.length > 0){
$("#responseText").text(data);
}
}
};
// ajaxForm
$("#form").ajaxForm(options); // ajaxSubmit
$("#form").ajaxSubmit(options);
});
});
</script>
jQuery异步提交form表单的更多相关文章
- jQuery.serialize() 提交form表单
serialize()函数用于序列化一组表单元素,将表单内容编码为用于提交的字符串. serialize()函数常用于将表单内容序列化,以便用于AJAX提交. 该函数主要根据用于提交的有效表单控件的n ...
- AJAX异步提交form表单
记录: 网上有说怎么做,没说怎么接收,打印了一下数据,记录一下取值: 比如说有如下form: <form id="form1" name="form1" ...
- asp.net mvc4 使用java异步提交form表单时出现[object object] has no method ajaxSubmit
最近接手了一个单子,说大不大,只是功能不少,开发过程中遇到该问题 先看脚本截图: 本以为是笔误,哪儿写错了,可是看来看去,都没发现有不合适的地方,对比过网上很多代码,都差不多,于是各种方式的,各种原因 ...
- jquery ajax 提交form表单 以及django后台接受
HTML <form id="project_file_upload" enctype="multipart/form-data" > <di ...
- Jquery通过Ajax方式来提交Form表单
今天刚好看到Jquery的ajax提交数据到服务器的方法,原文是: 保存数据到服务器,成功时显示信息. jQuery 代码: $.ajax({ type: "POST", url: ...
- jquery实现ajax提交form表单的方法总结
本篇文章主要是对jquery实现ajax提交form表单的方法进行了总结介绍,需要的朋友可以过来参考下,希望对大家有所帮助 方法一: function AddHandlingFeeToRefund( ...
- Ajax提交form表单内容和文件(jQuery.form.js)
jQuery官网是这样介绍form.js A simple way to AJAX-ify any form on your page; with file upload and progress s ...
- Jquery来对form表单提交(mvc方案)
来自:http://www.cnblogs.com/lmfeng/archive/2011/06/18/2084325.html 我先说明一下,这是asp.net mvc 里面的用法, Jquery来 ...
- 通过jQuery的Ajax方式来提交Form表单
通过jQuery的Ajax方式来提交Form表单 $.ajax({ url:ajaxCallUrl, type:"POST", cache:true, async:false, d ...
随机推荐
- Web跨域问题基础
同源策略(Same origin policy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响.可以说Web是构建在同源策略基础之上的,浏览器只 ...
- HDU 6182 A Math
A Math Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
- hbase xshell
用Xshell登陆linux主机后,在hbase shell下死活不能使用backspace和delete删除误输的指令,只得不停退出,重登,仔细输..又错了,再退出,再登,仔细输...又错了...又 ...
- 今日SGU 5.10
SGU 168 题意:从a矩阵求出b矩阵,规则直接看题目就行了,不好打字说明 收获:dp #include<bits/stdc++.h> #define de(x) cout<< ...
- 洛谷——P1209 [USACO1.3]修理牛棚 Barn Repair
https://www.luogu.org/problem/show?pid=1209 题目描述 在一个夜黑风高,下着暴风雨的夜晚,farmer John的牛棚的屋顶.门被吹飞了. 好在许多牛正在度假 ...
- SpringMVC & Struts2
这两个框架可谓Java中的经典,Java开发必懂的框架,这两天在面试中又问道两者的异同.这里简单做了整理供大家參考交流. 概念:
- [Angular & Unit Testing] Automatic change detection
When you testing Component rendering, you often needs to call: fixture.detectChanges(); For example: ...
- Problem C: Celebrity Split
题目描写叙述 Problem C: Celebrity Split Jack and Jill have decided to separate and divide their property e ...
- js14--原型2
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...
- battery-获取手机电量信息
我们如果想要获得手机的电池电量信息,可以借助广播来实现.因为当手机电池电量发生变化的时候,系统会发送一个广播.具体代码如下 //注册 intentFilter.addAction(Intent.ACT ...