引用(ajaxfileupload.js) ajaxfileupload.js报这错jQuery.handleError is not a function

jQuery.handleError is not a function 原因是,
经测试handlerError只在jquery-1.4.2之前的版本中存在,jquery-1.6 和1.7中都没有这个函数了,因此在1.4.2中将这个函数复制到了ajaxFileUpload.js中,
问题解决

handleError: function (s, xhr, status, e) {
        // If a local callback was specified, fire it
        if (s.error) {
            s.error.call(s.context || s, xhr, status, e);
        }

        // Fire the global callback
        if (s.global) {
            (s.context ? jQuery(s.context) : jQuery.event).trigger("ajaxError", [xhr, s, e]);
        }
    },



问题2:一直得到error ,无法执行指定的success方法。通过追踪ajaxFileUpload的执行过程发现,在调用它自身的uploadHttpData函数时,当执行if(type=="json") eval("data = "+data); 会抛出异常,导致在处理异常的时候将status = "error" 因此一直执行error方法。 上网查询,得知eval函数是用来执行一段js代码,而并不是如我所想的反解json串 eval("data = "+data);的意思是 将data 赋值给 data参数 ,但是当我返回给页面的是一个简单的字符串,比如"OK" ,时,这样写就抛出异常。最后改为 data = jQuery.parseJSON(jQuery(data).text());即使用新api json反序列化,然后赋给 data 。终于成功了。。。

原文地址:https://www.cnblogs.com/guojian/p/4308384.html