jquery ajax post方法获取json数据

前端


html>


    http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    </span>无标题文档<span style="color:#e8bf6a;">
    


 
  
type= "text" id= "price" > type= "button" id= "btn" value= "submit" >
heigh: id= "heigh" >
midle: id= "midle" >
low: id= "low" >

php


$k = $_POST [ "symbol" ] ;

switch
( $k ){
case 'msft' :
$v = array ( "h" => "100" , "m" => "80" , "l" => "50" ) ;
break
;

case 'goog' :
$v = array ( "h" => "200" , "m" => "180" , "l" => "150" ) ;
break
;

case 'aapi' :
$v = array ( "h" => "300" , "m" => "280" , "l" => "250" ) ;
break ;
}
$json
=json_encode( $v ) ;
header(
"content-type:application/json" ) ;
echo
$json ;

?>


你可能感兴趣的:(php)