我想遍历我的 json,但我遇到了问题。这是我的文件返回给我的json和我的代码
代码
var json=null;
$.getJSON("ajax_files/getmyjson.php?id="+id, function(json){
json = json[0];
alert(json.id);//这样就ok了,id=15
这是问题
var getReq = jQuery.parseJSON('['+json.property_req_1+']');
$.each(getReq, function(id, key) {
alert(id+'='+key);//not working
});
});
JSON
[{"id":"15",
"rand_key":"1234",
"landlord_name":"Shah",
"property_req_1":{
"lead_req_id":"",
"lead_id":"0",
"category_id":"1",
"region_id":"1",
"area_location_id":"17",
"sub_area_location_id":"3447",
"min_beds":"1",
"max_beds":"",
"min_budget":"3332",
"max_budget":"0",
"min_area":"",
"max_area":"0",
"unit_type":"2",
"unit_no":"",
"listing_id_1_ref":"RH-R-17",
"listing_id_1":"17"
}
}]