在此先感谢您的帮助。我是JSON的新手,我一直试图使用$ .getJSON填充一些表单字段,但没有运气。
我开始砍件,直到我离开只是为了测试从服务器我的回应(我的服务器提供时,下面列出的URL在浏览器中查看JSON):
$(document).ready(function(){
$('#button').live('click', function(){
$.getJSON('http://localhost:8000/core/api/master-assembly/16', function(data) {
// alert(data); // uncomment for debug
$('#showdata').html("<p>item1="+data.afAgeCounter+" item2="+data.afWordCounter+" item3="+data.idNumber+"</p>");
});
});
});
我的JSON数据看起来是像:
{"success":true,"data":{"afWordCounter":123,"afAgeCounter":456,"idNumber":789, ...
当我运行该脚本,我得到的输出:
物品1 =未定义ITEM2 =未定义的项目3 =不确定
如果我取消了
alert(data);
所有我得到的回报是[对象的对象]
那么这里给人?
再次感谢:)
不能提醒的对象,但是,您可以使用控制台.log(data)并在JavaScript调试器(如Firebug)中查看对象。 – jholloman 2012-07-26 21:50:26