JQuery. form Ajax no-refreshing upload error (jQuery. handleError is not a function) Solution
Today, when using ajaxfileupload, firebug reported a "jQuery. handleError is not a function" error. Because jQuery. form has never encountered this problem. I compared it with previous projects and found that jQuery is 1.10.2 in this project, but 1.4.2 was previously used. After du Niang, find the solution: jQuery. handleError is not a function. The error cause is:
HandlerError only exists in versions earlier than the jquery-1.4.2 and does not exist in Versions later than the jquery-1.4.2.
Therefore, this function is added in the jquery advanced version to solve the problem. This js Code segment can be added to jquer. js or 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; } });