JQuery. form Ajax no-refreshing upload error (jQuery. handleError is not a function) Solution

Source: Internet
Author: User

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;                }            });


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.