gpt4 book ai didi

jquery - 类型错误 : e is null error

转载 作者:行者123 更新时间:2023-12-01 04:03:22 26 4
gpt4 key购买 nike

我目前正在尝试将 AJAX GET 请求的结果放入 PhoneGap 中正在开发的应用程序的表中。但是我不断收到下面的错误,但无法找出原因。

TypeError: e is null

ajax结果如下:

[{ 
name: "test1"
},{
name: "test2"
}]

与之相关的代码是:

function getMatches() {
$.ajax({
type: 'GET',
dataType: "json",
url: 'url',
success: function(result){
console.log(result);
var jsonObj = $.parseJSON(result);
var html = '<table>';
$.each(jsonObj, function(key, value){
html += '<tr>';
html += '<td>' + key + '</td>';
html += '<td>' + value + '</td>';
html += '</tr>';
});
html += '</table>';
$( "div#results" ).replaceWith(html);
},
error: function(){
console.log(result);
alert('There was an error making getting your offers');
}
});
}

最佳答案

使用它:

$(document).ready(function(){

getMatches();
function getMatches() {
$.ajax({
type: 'GET',
dataType: "json",
url: 'url',
success: function(result){
console.log(result);
var jsonObj = result;
var html = '<table>';
$.each(jsonObj, function(key, value){
html += '<tr>';
html += '<td>' + key + '</td>';
html += '<td>' + value.name + '</td>';
html += '</tr>';
});
html += '</table>';
$( "div#results" ).replaceWith(html);
},
error: function(){
console.log(result);
alert('There was an error making getting your offers');
}
});
}
});

关于jquery - 类型错误 : e is null error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35509873/

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