任何人都能看到下面这个最小示例的问题吗?我在标题中包含了最新版本的jQuery。
jQuery(document).ready(function () { //<--- works normally
jQuery.ajax({ // <----- Error: "jQuery.ajax is not a function TypeError: jQuery.ajax is not a function"
url: "test.html",
context: document.body
}).done(function () {
jQuery(this).addClass("done");
});
...错误:
jquery-3.3.1.slim.min.js:2 jQuery.Deferred exception: jQuery.ajax is not a function TypeError: jQuery.ajax is not a function
at HTMLDocument.<anonymous> (xxxx)
at l (https://code.jquery.com/jquery-3.3.1.slim.min.js:2:29567)
at c (https://code.jquery.com/jquery-3.3.1.slim.min.js:2:29869) undefined发布于 2019-02-26 01:40:50
您在项目中包含了jQuery slim,它不支持jQuery.ajax。使用jQuery的完整版。
发布于 2019-02-26 01:41:19
如果您在jQuery中缺少函数,请确保您不是瘦版本(jquery-3.3.1.slim.min)。只需删除“.slim”。您期望的函数将会出现(jquery-3.3.1.min)。
https://stackoverflow.com/questions/54871772
复制相似问题