json response opens as dialogue box in php and json response format
$result=mysql_query("select * from pointtable where Latitude between '$latitude1' and '$latitude2' and Longitude between '$longitude1' and '$longitude2' ")开发者_如何学JAVA;
$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?...
try
while($post = mysql_fetch_assoc($result))
{
$posts[]=$post;
}
header('Content-type: text/plain');
echo json_encode($posts);
精彩评论