gpt4 book ai didi

ajax - 使用jquery ajax调用将json数据加载到div

转载 作者:行者123 更新时间:2023-12-01 06:34:57 25 4
gpt4 key购买 nike

任何人都可以告诉我下面给出的代码有什么问题吗?我正在尝试使用 json 调用在 div 中加载数据。

function getData() {
$.ajax({
url: "http://echo.jsontest.com/key/value/one/two",
type: "get",
dataType: "JSON"
}, function(data){
$('#99').append(JSON.stringify(data));
});
return false;
}

如果有人能够对 $.ajax、$.get、$.post 和 $.getJSON 进行一些了解

最佳答案

您正在混合 $.get$.ajax

改用这个:

$.ajax({
url: "http://echo.jsontest.com/key/value/one/two",
dataType: "json"
}).success(function(data){
$('#data').append(JSON.stringify(data));
});

演示:http://jsfiddle.net/j3vsg/

关于ajax - 使用jquery ajax调用将json数据加载到div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18548017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com