jQuery getJSON报告了未定义的函数错误

时间:2018-07-22 12:48:02

标签: jquery undefined getjson

我正在尝试在加载页面时加载json文件。所以我尝试了这段代码:

$( document ).ready(function() {
    $.getJSON("./db/url.json", function(json) {
        console.log(json); 
    });
    console.log("The page is loaded"); 
});

导致此错误:

 [Show/hide message details.] TypeError: $.getJSON is not a function[Learn More]

我阅读了一些类似的帖子,但仍然无法弄清楚。你能帮忙吗?

如果使用$.ajax

,结果相同

1 个答案:

答案 0 :(得分:0)

请确保您没有使用slim版本(链接中有差异)。 精简版不包含.ajax.getJSON

可以在here中找到

jquery-3.1.1.min.js的完整版本。

测试并检查结果。