我怀疑我的问题是由于我的JSON字符串的结构。它似乎在JSON对象中有一个JSON对象。无法用jQuery解析JSON,返回[object Object]
这是我的JSON格式:
[
{"subject":{"title":"java","id":"1","desc":"Basic java programming"},
{"subject":{"title":"objective c","id":"2","desc":"Introduction to objective c"}
}
这是我的jQuery代码:
var items = [];
$.getJSON('theurl', function(data) {
$.each(data, function(key, subject) {
alert(subject); //returning me "[object Object]"
$('#tempresult').append('<p>'+ subject +'</p>'); //returning me "[object Object]"
});
});
这看起来正确根据你的对象。你想要什么? – gilly3