查看jQuery file upload的image preview如何工作的
查看readme中的说明,
- JavaScript Load Image library v. 1.13.0+: Required for the image previews and resizing functionality.
- JavaScript Canvas to Blob polyfill v. 2.1.1+:Required for the image previews and resizing functionality.
注释掉这个js的引用
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<!--<script src="//blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"></script>-->
然后发现错误在loadImage.parseMetaData,提示loadImage undefined
loadImageMetaData: function (data, options) {
if (options.disabled) {
return data;
}
var that = this,
dfd = $.Deferred();
loadImage.parseMetaData(data.files[data.index], function (result) {
$.extend(data, result);
dfd.resolveWith(that, [data]);
}, options);
return dfd.promise();
},

在loadImageMetaData函数前面,加上console.trace(); 刷新页面,再次尝试,然后查看stack trace,但是这个结果没有意义。可读性太差了。
使用stacktrace.js查看堆栈信息
引用https://cdnjs.cloudflare.com/ajax/libs/stacktrace.js/2.0.0/stacktrace.js,然后在loadImageMetaData函数处,输出堆栈信息
var callback = function(stackframes) {
var stringifiedStack = stackframes.map(function(sf) {
return sf.toString();
}).join('\n');
console.log(stringifiedStack);
};
var errback = function(err) { console.log(err.message); };
StackTrace.get().then(callback).catch(errback);
loadImageMetaData()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-image.js:289:28
func()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:84:65
_processFile: function (data, originalData) {
var that = this,
dfd = $.Deferred().resolveWith(that, [data]),
chain = dfd.promise();
this._trigger('process', null, data);
$.each(data.processQueue, function (i, settings) {
var func = function (data) {
if (originalData.errorThrown) {
return $.Deferred()
.rejectWith(that, [originalData]).promise();
}
return that.processActions[settings.action].call(
that,
data,
settings
);
};
chain = chain.then(func, settings.always && func);
});
chain
.done(function () {
that._trigger('processdone', null, data);
that._trigger('processalways', null, data);
})
.fail(function () {
that._trigger('processfail', null, data);
that._trigger('processalways', null, data);
});
return chain;
},
function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3305:32
apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29
add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6
function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3304:28
callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22
jQuery.each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3301:13
promise.promise()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3361:8
jQuery.Deferred(function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3300:19
_processFile/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:90:31
chain = chain.then(func, settings.always && func);
callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22
_processFile()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:78:15
$.each(data.processQueue, function (i, settings) {
$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25
returnValue = value.apply( this, arguments );
func()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:153:41
return that._processFile(opts, data);
function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3305:32
apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29
add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6
function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3304:28
callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22
jQuery.each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3301:13
promise.promise()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3361:8
jQuery.Deferred(function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3300:19
process/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:157:67
that._processingQueue = that._processingQueue.then(func, func)
callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22
process()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-process.js:146:19
$.each(data.files, function (index) {
$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25
returnValue = value.apply( this, arguments );
$.widget.bridge/$.fn[name]/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:220:39
methodValue = instance[ options ].apply( instance, args );
callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22
each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:136:16
$.widget.bridge/$.fn[name]()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:206:9
this.each(function() {
add/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-ui.js:115:34
return $this.fileupload('process', data);
function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3305:32
apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29
add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6
function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3304:28
callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22
jQuery.each()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3301:13
promise.promise()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3361:8
jQuery.Deferred(function()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3300:19
_addConvenienceMethods/data.process()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:663:27
).then(resolveFunc, rejectFunc);
add()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload-ui.js:114:22
data.process(function () {
_trigger()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:527:13
callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
event.isDefaultPrevented() );
_onAdd/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1037:31
result = that._trigger(
'add',
$.Event('add', {delegatedEvent: e}),
newData
);
callback.apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:384:22
_onAdd()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1030:15
$.each(fileSet || files, function (index, element) {
$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25
returnValue = value.apply( this, arguments );
_onChange/<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1236:26
that._onAdd(e, data);
apply()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3148:29
add()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3194:6
always()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:3295:14
_onChange()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/jquery.fileupload.js:1226:53
this._getFileInputFiles(data.fileInput).always(function (files) {
$.widget/</proxiedPrototype[prop]</<()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:127:25
handlerProxy()@http://172.31.212.20:8082/jQuery-File-Upload-Demo/js/vendor/jquery.ui.widget.js:438:7
return ( typeof handler === "string" ? instance[ handler ] : handler )
.apply( instance, arguments );
event.namespace_re.test()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:4670:8
handle()@http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.js:4338:27
查看jQuery file upload的image preview如何工作的的更多相关文章
- jQuery File Upload
jQuery File Upload介绍.............................................. 2 实现基本原理......................... ...
- 定制jQuery File Upload为微博式单文件上传
日志未经声明,均为AlloVince原创.版权采用『 知识共享署名-非商业性使用 2.5 许可协议』进行许可. jQuery File Upload是一个非常优秀的上传组件,主要使用了XHR作为上传方 ...
- jQuery File Upload 单页面多实例的实现
jQuery File Upload 的 GitHub 地址:https://github.com/blueimp/jQuery-File-Upload 插件描述:jQuery File Upload ...
- 用jQuery File Upload做的上传控件demo,支持同页面多个上传按钮
需求 有这么一个需求,一个form有多个文件要上传,但又不是传统的图片批量上传那种,是类似下图这种需求,一开始是用的swfupload做的上传,但是问题是如果有多个按钮的话,就要写很多重复的代码,于为 ...
- jQuery File Upload blueimp with struts2 简单试用
Official Site的话随便搜索就可以去了 另外新版PHP似乎都有问题 虽然图片都可以上传 但是response报错 我下载的是8.8.7木有问题 但是8.8.7版本结合修改main. ...
- jQuery File Upload done函数没有返回
最近在使用jQuery File Upload 上传图片时发现一个问题,发现done函数没有callback,经过一番折腾,找到问题原因,是由于dataType: ‘json’造成的,改为autoUp ...
- jquery file upload 文件上传插件
1. jquery file upload 下载 jquery file upload Demo 地址:https://blueimp.github.io/jQuery-File-Upload/ jq ...
- jQuery File Upload跨域上传
最近在做一个一手粮互联网项目,方案为前后端分离,自己负责前端框架,采用了Requirejs+avalonjs+jquery三个框架完成. 前后端通过跨域实现接口调用,中间也发现了不少问题,尤其是在富文 ...
- jquery ajax发送delete(use in jquery file upload delete file)
环境: jQuery file upload HTML example code <div class="pic-preview"> <div class=&qu ...
随机推荐
- 使用Object.create()实现继承 用 Object.create实现类式继承
使用Object.create()实现继承:https://www.cnblogs.com/cuew1987/p/4075027.html 用 Object.create实现类式继承:https:// ...
- BSP中uboot初体验
一. uboot源码获取 1.1. 从板级厂家获取开发板BSP级uboot(就是由开发板厂家提供的) 1.2. 从SOC厂家获取相同SOC的BSP级uboot 1.3. 从uboot官方下载 1.4. ...
- MY SQL数据库密码最简单的一个方法()
https://zhidao.baidu.com/question/564368111.html 非常简单的一个修改方法!!!!!!!!!!!!!!!!!!!!! 最简单的方法就是借助第三方工具Nav ...
- HDU 1594 find the max
数序问题. 题意是说 一个数列 a1,a2,--ai,--an; x=i , y = ai:找两个点斜率绝对值.!最大. 第一次没找绝对值,--认真读题. .. x 每次加1 . 仅仅须要找 相邻的 ...
- SpringMVC简单介绍及执行
SpringMVC介绍 Spring MVC是Spring提供的一个强大而灵活的web框架.借助于注解,Spring MVC提供了几乎是POJO的开发模式,使得控制器的开发和测试更加简单.这些控制器一 ...
- HTTP1.0、HTTP 1.1、HTTP 2.0之间的主要区别
HTTP1.0与HTTP 1.1的主要区别 长连接 节约带宽 HOST域 HTTP1.1与HTTP 2.0的主要区别 多路复用 二进制分帧 首部压缩 服务器推送 一.HTTP1.0与HTTP 1. ...
- man.conf - man的设定资料
描述 man(1) man(1) 会 读 取 本 档 . man.conf 的 内 容 包 含 了 (a) 如 何 建 立 man 搜 寻 路 径 的 资 讯 , (b) man 所 使 用 的 程 ...
- 025-Cinder服务-->安装并配置一个本地存储节点(ISCSI)
一:Cinder提供块级别的存储服务,块存储提供一个基础设施为了管理卷,以及和OpenStack计算服务交互,为实例提供卷.此服务也会激活管理卷的快照和卷类型的功能,块存储服务通常包含下列组件:cin ...
- npm 在安装的时候提示 没有权限操作的解决办法 Error: EACCES: permission denied
十分感谢https://blog.csdn.net/ldqsxsl/article/details/75059607的帮助! 错误原因:权限错误,需要root用户. 解决办法:就是把用户目录下的 .n ...
- 3--面试总结-es6
es6文档:http://es6.ruanyifeng.com/1.es6新特性 let/const 变量的解构赋值(数组的解构赋值,对象的解构赋值,字符串的解构赋值,数值和布尔值的解构赋值,函数参数 ...