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 ...
随机推荐
- 10.axis实现webservices分布式通信
转自:https://www.aliyun.com/jiaocheng/310112.html 分布式通信原理 基本原理:stub和skeleton作为客户端和服务端传输的中介,stub和skelet ...
- js -- img 随着鼠标滚轮的变化变化
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- ArcGIS “Error HRESULT E_FAIL has been returned from a call to a COM component.” 异常的解决
错误提示内容: {System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been ret ...
- [Angular & Unit Testing] Testing Component with Store
When using Ngrx, we need to know how to test the component which has Router injected. Component: imp ...
- 6.Windows 二进制文件 (.exe)安装--终端安装
转自:http://www.runoob.com/nodejs/nodejs-tutorial.html 32 位安装包下载地址 : http://nodejs.org/dist/v0.10.26/n ...
- 快速排序的期望复杂度O(nlogn)证明。
快速排序的最优时间复杂度是 \(O(nlogn)\),最差时间复杂度是 \(O(n^2)\),期望时间复杂度是 \(O(nlogn)\). 这里我们证明一下快排的期望时间复杂度. 设 \(T(n)\) ...
- java根据url获取完整域名
private String getDomain(String destination){ if(destination==null||destination.trim().equals(" ...
- elasticsearch选举master
数据节点确定了master以后.会开启MasterPinger线程来与其保持心跳通信的逻辑假设通信过程中链接断开,会通过MasterNodeFailureListener监听器进行回调处理处理过程中会 ...
- VPS的centOS6安装远程桌面
VPS的centOS6安装远程桌面 64位系统的需要编译安装 ttp://www.landui.com/help/Show-991.html xrdp是在图形界面下使用的,首先要确定您的centos系 ...
- HTML基础第七讲---框架
转自:https://i.cnblogs.com/posts?categoryid=1121494 框架(Frame)也就是所谓的分割窗口.分割画面.框窗效果(还真是五花八门),这个技巧在运用上问题比 ...