我是新手,所以轻松一点:
我不明白为什么这个 $.ajax 函数不会将我的 xhr 数据附加到正确的位置。
// gets the cache data from our php file
function getcaches() {
$.ajax({
method: 'get',
url: "php/findcache.php",
dataType: "json", // return type data is json
success: function(data){ // <-- data is in json format
//parse the json data
$('#caches').append($('<p>' + data[0].name + '</p>'));
},
error: function(data) {
console.log('error');
}
});
return false;
}
那是相关的javascript。我知道数据已正确存储在对象中,因为我可以在萤火虫中看到它...
[OU0397] => stdClass Object
(
[code] => OU0397
[name] => A Mighty Oak in the Open
[location] => 28.527633|-81.125167
[type] => Virtual
[status] => Available
)
我只是不明白我做错了什么。任何指针?