Uncaught TypeError: jQuery(...).data(...) is not a function

One, the background:

It has been running a proper ajax form submission page, today reported the following error:

 

Second, the problem analysis:

"Uncaught TypeError" This type of error usually occurs, the following four reasons:

1: js introduced inside the function undefined undefined

This is generally a function to check whether a change can be. After the general replacement of the new version of the old version of js js possible, there is no method. This time you can manually put the old version of js methods to the new version, or to change the method.

For example, we encountered  handleError  IS A function not this case is the reason. If you add this function in the jquery advanced version, the problem is solved.

; (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;

                }

            });[/code]
View Code

 

2: Your js file path to the introduction of mistakes.

This is more common, the introduction of the path is correct can be checked.

3: js file that you introduced with other js files that have conflicts

This time we need to comment out one by one js file for troubleshooting.

4: js files in the order you not introduced, there is a conflict, you have to adjust the order of introduction to, or delete files js conflict, which is the case of small series of encounters!

Third, the problem is solved:

The reason I question belongs to the fourth case. In the page template the page where the problem lies in the (master) which cited jquery.form.js this document and H-ui.min.js, H-ui.admin.js conflict.

The method uses a reference into the jquery.form.js H-ui.min.js, H-ui.admin.js two front

 

Guess you like

Origin www.cnblogs.com/sunxi/p/11039524.html