$result=mysql_query("select * from pointtable where Latitude between '$latitude1' and '$latitude2' and Longitude between '$longitude1' and '$longitude2' ");
$posts=array();
if(mysql_num_rows($result))
{
while($post = mysql_fetch_assoc($result))
{
$posts[]=array('post'=>$post);
}
}
header('Content-type: application/json');
echo json_encode(array('posts'=> $posts));
上面的代码是创建json response..i有一个表单,通过POST方法,我得到参数信息..结果很好,但它在diagloue框中打开..我想在页面中键入此json响应。 ..我该怎么做?..
{"posts":[{"post":{"id":"1","LayarType":"college","Attribution":"Daiict","Title":"CEP Daiict","Latitude":"23.3400000000","Longitude...}
我不想要这个开始... {“帖子”:“发布'} ..想从{id:1 ...}开始 我有什么改变?...
答案 0 :(得分:1)
试
while($post = mysql_fetch_assoc($result))
{
$posts[]=$post;
}
header('Content-type: text/plain');
echo json_encode($posts);