jQuery.form Ajax无刷新上传错误 (jQuery.handleError is not a function) 解决方案

        今天,随着ajaxfileupload时间firebug财报显示,“jQuery.handleError is not a function”错误。因为一旦使用jQuery.form问题,我对照曾经的项目才发现,在这个项目中使用的jQuery是1.10.2的版本号,而曾经是使用的1.4.2。度娘一番之后,找到解决的方法:jQuery.handleError is not a function 报错原因是:
handlerError仅仅在jquery-1.4.2之前的版本号中存在。jquery-1.4.2之后的版本号中都没有这个函数了。

因此在jquery高级版本号中将这个函数加入上 ,问题解决。 该js代码段能够加在jquer.js或者ajaxfileupload.js中。


; (function ($) {
            jQuery.extend({
                handleError: function (s, xhr, status, e) {
                    if (s.error) {
                        s.error.call(s.context || s, xhr, status, e);
                    }
                    if (s.global) {
                        (s.context ? jQuery(s.context) : jQuery.event).trigger("ajaxError", [xhr, s, e]);
                    }
                },
                httpData: function (xhr, type, s) {
                    var ct = xhr.getResponseHeader("content-type"),
            xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
            data = xml ?

xhr.responseXML : xhr.responseText; if (xml && data.documentElement.tagName == "parsererror") throw "parsererror"; if (s && s.dataFilter) data = s.dataFilter(data, type); if (typeof data === "string") { if (type == "script") jQuery.globalEval(data); if (type == "json") data = window["eval"]("(" + data + ")"); } return data; } });



版权声明:本文博客原创文章。博客,未经同意,不得转载。

原文地址:https://www.cnblogs.com/mengfanrong/p/4637554.html