我有一个JSON文件样例。
{a:'spc432',
b:'lll432'
}
我正在尝试从客户端获取JSON文件,同时HTML也仅在客户端编写。
之后,我想要动态地从JSON文件中找到每个ID。我们如何在知道JSON文件ID的情况下获取IDs ..?
我尝试了下面的代码,但它没有起作用。你能帮忙看一下吗?
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.5.js"></script>
<script>
$(document).ready(function(){
alert("hi");
$.get("json_text.txt", function(data)
{ alert("length = "+data.length);
for( i = 0; i< data.length; i++)
alert("key name "+data[i].id);
}
);
});
</script>
</head>
<body>
</body>
</html>