含有文件的form表单用jquery提交
来源:互联网 发布:一彩送货单软件 编辑:程序博客网 时间:2024/06/16 04:15
近期做项目遇到此问题,含有文件上传的form表单用ajaxSubmit提交,在此记录下,代码如下:
<form id="excelForm" name="excelForm" enctype="multipart/form-data" method="post">
<table>
<tr>
<td width="120" align="right" bgcolor="#f4f4f4">选择文件:<span style='color:red;'></span></td>
<td><input type="file" name="file" id="file"></td>
<td><input type="button" value="导入" onclick="excelImport()"></td>
</tr>
<tr>
<td width="120" align="right" bgcolor="#f4f4f4">示例模板:</td>
<td bgcolor="white">
<img height="20" with=" 30" src="/static/images/slmb.png"/><a href="javascript:location=encodeURI(encodeURI('/servlet/download.do?file_path=电话号码导入模板.xls&file_name=/hgj/hgjSms/telNo.xlsx'))">点击下载</a>
</td>
</tr>
</table>
</form>
function excelImport(){
//校验是否选择文件
var file = $("#file").val();
if(file == null || file == ""){
alert("请选择文件!");
return false;
}
$("#excelForm").ajaxSubmit({
url : '/hgjSms/excelImport.htm',
type : 'POST',
success : function(data){
var obj = eval("("+data+")");
if(obj.resultType == "-1"){
alert("文件中以下行中的号码格式不正确:" + obj.resultStr);
return;
}else if(obj.resultType == "-2"){
alert("选择的文件未读到手机号码");
return;
}else if(obj.resultType == "-3"){
alert("系统异常");
return;
}else {
$("#checkCount").html(obj.memberCount);
$("#sendCount").html(obj.memberCount);
$("input[name='tel']").each(function(){
$(this).attr('disabled',false);
});
}
}
})
}
- 含有文件的form表单用jquery提交
- 用jquery.form.js 实现ajax提交含有上传文件和普通字段的表单
- jquery提交带上传文件的form表单
- 用jquery.form ajax提交文件上传表单
- html5里使用ajax提交含有上传文件的form表单
- ajax异步提交含有文件的表单
- jquery 提交form表单
- jquery 提交form表单
- jquery 提交form 表单
- jQuery提交form表单
- JQuery提交表单form
- form表单的提交相关的jquery
- jquery.form.js提交form表单 上传文件
- JQuery 阻止 Form 表单提交的方法
- jQuery提交Form表单的正确方式
- js jquery提交form表单的方式
- jquery的ajax提交form表单
- jquery的异步提交表单(异步上传文件)及jquery.form.js上传文件注意事项
- MAC下安装Microsoft软件
- Postgresql相关
- MingW Autotools 编写Vala程序 之一
- 数据库建表操作SQL代码大全
- Linux下MySQL的安装
- 含有文件的form表单用jquery提交
- web.xml初始化顺序
- C++和java多态的区别
- iOS证书说明和发布
- [刷题]Best Time to Buy and Sell Stock III
- 轻松搞定面试中的链表题目
- 收集的Android开源框架及其地址(备用)
- oracle 与OS的存储结构
- AtomicBoolean的妙用