以https://github.com/blueimp/jQuery-File-Upload/blob/master/basic-plus.html为例

注释掉load-image.all.min.js

  1. <!--script src="//blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js"></script-->

jquery.fileupload-image.js:279 Uncaught TypeError: Cannot read property 'parseMetaData' of undefined
at $.<computed>.<computed>.loadImageMetaData (jquery.fileupload-image.js:279)
at $.<computed>.<computed>.func (jquery.fileupload-process.js:84)
at $.<computed>.<computed>.<anonymous> (jquery.js:3305)
at fire (jquery.js:3148)
at Object.add [as done] (jquery.js:3194)
at Array.<anonymous> (jquery.js:3304)
at Function.each (jquery.js:384)
at Object.<anonymous> (jquery.js:3301)
at Function.Deferred (jquery.js:3361)
at Object.then (jquery.js:3300)

jquery.fileupload-process.js:84

  1. _processFile: function (data, originalData) {这个函数中
  1. return that.processActions[settings.action].call(
    that,
    data,
    settings
    );

jquery.fileupload-process.js:153

_processFile函数,被process函数调用

  1. // Processes the files given as files property of the data parameter,
    // returns a Promise object that allows to bind callbacks:
    process: function (data) {
  1. $.each(data.files, function (index) {
    var opts = index ? $.extend({}, options) : options,
    func = function () {
    if (data.errorThrown) {
    return $.Deferred()
    .rejectWith(that, [data]).promise();
    }
    return that._processFile(opts, data);
    };

jquery.fileupload.js:217

  1. // The add callback is invoked as soon as files are added to the fileupload
    // widget (via file input selection, drag & drop, paste or add API call).
    // If the singleFileUploads option is enabled, this callback will be
    // called once for each file in the selection for XHR file uploads, else
    // once for each file selection.
    //
    // The upload starts when the submit method is invoked on the data parameter.
    // The data object contains a files property holding the added files
    // and allows you to override plugin options as well as define ajax settings.
    //
    // Listeners for this callback can also be bound the following way:
    // .bind('fileuploadadd', func);
    //
    // data.submit() returns a Promise object and allows to attach additional
    // handlers using jQuery's Deferred callbacks:
    // data.submit().done(func).fail(func).always(func);
    add: function (e, data) {
    if (e.isDefaultPrevented()) {
    return false;
    }
    if (data.autoUpload || (data.autoUpload !== false &&
    $(this).fileupload('option', 'autoUpload'))) {
    data.process().done(function () {
    data.submit();
    });
    }
    },

先执行$(this).fileupload('option', 'autoUpload'),触发了jquery.ui.widget.js中的代码

  1. var widget_uuid = 0,
    widget_slice = Array.prototype.slice;
  1. $.fn[ name ] = function( options ) {
    //对三个变量进行赋值
    var isMethodCall = typeof options === "string",
    args = widget_slice.call( arguments, 1 ),
    returnValue = this;

这里的name是fileupload,options是option

arguments有2个元素, 0:option, 1:autoUpload

args经过赋值之后是autoUpload

  1. if ( isMethodCall ) {
    this.each(function() {
    var methodValue,
    instance = $.data( this, fullName );

fullName是blueimp-fileupload

经过赋值后

data函数调用触发了jquery中的函数

data: function( elem, name, data ) {
return internalData( elem, name, data );
},

elem是id为fileupload的input控件

name是blueimp-fileupload

经过赋值后,instance是fileupload的一个对象,这个对象包含一些数组元素,比如option

  1. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
    return $.error( "no such method '" + options + "' for " + name + " widget instance" );
    }

instance[options]是一个函数,这个函数是jquery.ui.widget.js中定义的,因为blueimp-fileupload扩展了,所以blueimp-fileupload也包含这么一个函数

  1. option: function( key, value ) {
    var options = key,
    parts,
    curOption,
    i;
  1. args经过赋值之后是autoUpload
    methodValue = instance[ options ].apply( instance, args );

因为上面的apply调用只传递了一个参数autoUpload

option: function( key, value ) {
var options = key,
parts,
curOption,
i;

  1. else {
    if ( arguments.length === 1 ) {
    return this.options[ key ] === undefined ? null : this.options[ key ];
    }

返回的methodValue是false

jQuery file upload上传图片出错分析的更多相关文章

  1. jQuery file upload上传图片的流程

    先触发_onChange[jquery.fileupload.js] _onChange: function (e) { var that = this, data = { fileInput: $( ...

  2. jQuery File Upload 插件 php代码分析

    jquery file upload php代码分析首先进入构造方法 __construct() 再进入 initialize()因为我是post方式传的数据  在进入initialize()中的po ...

  3. jQuery File Upload done函数没有返回

    最近在使用jQuery File Upload 上传图片时发现一个问题,发现done函数没有callback,经过一番折腾,找到问题原因,是由于dataType: ‘json’造成的,改为autoUp ...

  4. 用jQuery File Upload做的上传控件demo,支持同页面多个上传按钮

    需求 有这么一个需求,一个form有多个文件要上传,但又不是传统的图片批量上传那种,是类似下图这种需求,一开始是用的swfupload做的上传,但是问题是如果有多个按钮的话,就要写很多重复的代码,于为 ...

  5. jQuery File Upload blueimp with struts2 简单试用

    Official Site的话随便搜索就可以去了 另外新版PHP似乎都有问题  虽然图片都可以上传  但是response报错  我下载的是8.8.7木有问题   但是8.8.7版本结合修改main. ...

  6. jQuery File Upload 单页面多实例的实现

    jQuery File Upload 的 GitHub 地址:https://github.com/blueimp/jQuery-File-Upload 插件描述:jQuery File Upload ...

  7. jQuery File Upload文件上传插件简单使用

    前言 开发过程中有时候需要用户在前段上传图片信息,我们通常可以使用form标签设置enctype=”multipart/form-data” 属性上传图片,当我们点击submit按钮的时候,图片信息就 ...

  8. jquery file upload示例

    原文链接:http://blog.csdn.net/qq_37936542/article/details/79258158 jquery file upload是一款实用的上传文件插件,项目中刚好用 ...

  9. jquery file upload + asp.net 异步多文件上传

    百度了很久,国内一直 找不到 使用jquery file upload 插件 +asp.net 的相关代码 一开始使用 jquery uploadify ,一款基于 flash的插件,但是不支持 Sa ...

随机推荐

  1. Homebrew学习(二)之安装、卸载、更新

    安装 1.网上的安装方法都是用curl,从官网找到命令复制到终端,然后回车,结果报错请求超时 /usr/bin/ruby -e "$(curl -fsSL https://raw.githu ...

  2. 22、nlpir 人工智能

    练习介绍 [程序功能] 我们将完成一个和语义识别相关的爬虫程序,输入任意词汇.句子.文章或段落,会返回联想的词汇. [背景信息] 有一个非常牛的处理语言的网站nlpir,上面有非常多的处理语言的功能( ...

  3. Linux文件读写笔记

    读文件: #include <stdio.h> #include <stdlib.h> #include <unistd.h> //linux下面的头文件 #inc ...

  4. 使用MEMCACHED实现缓存

    什么是memcached Memcached是一个自由开源的,高性能,分布式内存对象缓存系统. Memcached是以LiveJournal旗下Danga Interactive公司的Brad Fit ...

  5. 2019.9.17更换ubuntu的镜像源 ubuntu安装lamp iis安装网站和ftp站

    更换ubuntu的镜像源 /etc/apt/sources.list cp  /etc/apt/sources.list  /etc/apt/sources.list.bak 备份这个文件 vim / ...

  6. php 简单删除提示

    下面是别的网友整理的,大同小异.一般通过弹出确认按钮来判断是否继续进入下面的删除页面. 第一种: <a href="javascript:if(confirm('确认删除吗?'))wi ...

  7. Centos6 修复grub损坏故障

    1.查看系统中的/boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to reru ...

  8. (转) weblogic 12c忘记密码

    weblogic安装后,很久不用,忘记访问控制台的用户名或者密码,可通过以下步骤来重置用户名密码. 说明:%DOMAIN_HOME%:指WebLogic Server 域(Domain)目录 我的是: ...

  9. Atcoder Regular 097 相邻球交换目的递增DP

    A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_bac ...

  10. tensorboard_embedding

    from tensorboardX import SummaryWriter import torchvision writer=SummaryWriter(log_dir="embeddi ...