<script type="text/javascript">
$(document).ready(function(){
$("#button").click(function(){
alert ("good");
$.getJSON("http://localhost/index.php/users", function(json){
$.each(json, function(idx, obj) {
alert(obj.name);
});
});
});
});
</script>
json格式:
[{"user_id":"2","username":"guest2","name":"John","profile_pic":""},{"user_id":"1","username":"guest","name":"tom","profile_pic":""}]
json的格式对于解析非常重要,一定要规范化
No comments:
Post a Comment