FormData异步上传
2024-10-19 01:08:42
1.代码片段一:
ajaxUpload: function () {
var url = this.$avatarForm.attr('action'),
data = new FormData(this.$avatarForm[0]),
_this = this; $.ajax(url, {
type: 'post',
data: data,
dataType: 'json',
processData: false,
contentType: false, beforeSend: function () {
_this.submitStart();
}, success: function (data) {
_this.submitDone(data);
}, error: function (XMLHttpRequest, textStatus, errorThrown) {
_this.submitFail(textStatus || errorThrown);
}, complete: function () {
_this.submitEnd();
}
});
},
2.代码片段二:
$(document).ready(function (e) {
$("#uploadForm").on('submit',(function(e) {
e.preventDefault();
$.ajax({
url: "upload.php",
type: "POST",
data: new FormData(this),
contentType: false,
cache: false,
processData:false,
success: function(data)
{
$("#targetLayer").html(data);
},
error: function()
{
}
});
}));
});
最新文章
- Nginx+Keepalived(带Nginx监控脚本)
- 新平台,新版本,ComponentOne 持续发力
- 最牛逼android上的图表库MpChart(二) 折线图
- POJ 1329 Circle Through Three Points(三角形外心)
- SCOM资源池
- http://www.mxchip.com/talk/news/jishuwenzhang/2014-09-11/67.html
- GO语言中的指针
- yii图片上传
- JSP中的相对路径和绝对路径(转)
- rowid去重(删除表的重复记录)
- React文档翻译 (快速入门)
- python基础之数据类型与变量
- SUSE11sp3 perf工具安装过程
- 在安卓手机上通过虚拟机运行Windows XP
- mysql分区方案的研究
- kill、killall、pkill杀手三人组
- ubuntu下截图工具推荐 -- [deepin-scrot]
- 移动端自动化测试-WTF Appium?
- swift中UIImageView的创建
- Linux下Tomcat的启动、关闭
热门文章
- 父元素没有设置定位 position absolute 解析
- git gui :Updating the Git index failed. A rescan will be automatically started to res
- 解决Android SDK Manager下载问题和android studio每次启动都要在fetching Android sdk compoment information
- chrome 禁止自动更新
- iOS-仿智联字符图片验证码
- nginx根据token做频率限制
- 在一个SQL Server表中一行的多个列找出最大值
- Js/jQuery实时监听输入框值变化
- laravel 数据库查询的一些函数意义(未完)
- IOS基于XMPP协议开发--XMPPFramewok框架(二):服务器连接