-1
我目前正在嘗試將AJAX GET
請求的結果放入PhoneGap中正在開發的應用程序的表中。但是,我不斷收到下面的錯誤,不知道爲什麼。解決了:TypeError:e爲null錯誤
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');
}
});
}
我覺得你不要不需要$ .parseJSON – Sandeep
你似乎是對的,至少我得到輸出。但是它顯示爲: [object Object] [object Object] 我在想什麼? –
對得到JSON對象。如果你把它轉換爲字符串使用JSON.stringify(jsonObj) – Sandeep