json响应以php和json响应格式打开为对话框

时间:2011-05-24 03:13:24

标签: php json

$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 ...}开始 我有什么改变?...

1 个答案:

答案 0 :(得分:1)

while($post = mysql_fetch_assoc($result))
  {
    $posts[]=$post;
  }
header('Content-type: text/plain');
echo json_encode($posts);
相关问题