duanfan8699 2011-05-24 03:13
浏览 64

json响应以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));

above code is of creating json response..i have one form from which by POST method i am getting parameter information..result is fine but it opens in diagloue box..i want to type this json response in a page...what do i do?..

{"posts":[{"post":{"id":"1","LayarType":"college","Attribution":"Daiict","Title":"CEP Daiict","Latitude":"23.3400000000","Longitude...}

i donot want this starting...{"posts":"post'}..want to start it from {id:1...} what do i change?...

  • 写回答

1条回答 默认 最新

  • doushantun0614 2011-05-24 05:15
    关注

    try

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度