我是使用 Json 的新手,我想从 Json array 获取 Particular Id 数据。
这是我正在使用的 api 网址。
http://example/plapi/areas?jsoncallback=?
这个返回 json 数组的 url 像
([{"area_id":"25","ca_id":"0","area_name":"Durgapuram","alias_area":"","area_spl":"No","area_lat":"16.52069","area_lng":"80.64067","area_desc":"","area_image":"","map_image":"","area_status":"1","city_id":"27","position":"0","m_keyword":""},{"area_id":"26","ca_id":"0","area_name":"Arundalpet","alias_area":"","area_spl":"No","area_lat":"16.30520","area_lng":"80.44169","area_desc":"","area_image":"","map_image":"","area_status":"1","city_id":"31","position":"0","m_keyword":""})]
在那我只想获取数据city_id = 31。
要获得 id 为 31 的数据,我正在这样做
var data = {
"id": "31",
};
$.getJSON("http://example/plapi/areas?jsoncallback=?",JSON.stringify(data) ,function(result){console.log(result);
});
但它什么也没返回。
我只想获得 31 个 id 相关数据而不是其他数据。请帮我怎么办?