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

问题描述 投票:1回答:1

我正在尝试加载页面时加载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,结果相同

jquery undefined getjson
1个回答
0
投票

确保您不使用slim版本(差异在附加的链接中)。超薄版不包括.ajax.getJSON

jquery-3.1.1.min.js的完整版本可以找到here

测试并检查结果。

© www.soinside.com 2019 - 2024. All rights reserved.