分享

JQuery $.getJSON与PHP的使用

 明天网吧 2015-03-21

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www./1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试文档</title>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
</head>

<body>
<script language="javascript" type="text/javascript">
function getjs()
{
 $.getJSON("aaa.php?module=yes&rid="+Math.random(),{ids:[111,222,333,444,555].join(",")},function(data){
  for(var i=0;i<data.length;i++){
   alert(data[i].id);
  }
 });
}
</script>
<input type="button" value="测试" onClick="javascript:getjs();"/>
</body>
</html>

 

<?php
$ids=$_GET["ids"];
$ids=explode(',',$ids);
//$arr=array("name"=>"姓名", "age"=>20,'A'=>$ids);
$arr=array();
$arr[]=array('id'=>$ids[0],'price_now'=>'0.00','time_now'=>'161427','u_name_now'=>'abc','state'=>'1','bidDisabled'=>'0');
$arr[]=array('id'=>$ids[1],'price_now'=>'0.00','time_now'=>'161427','u_name_now'=>'abc','state'=>'1','bidDisabled'=>'0');
$arr[]=array('id'=>$ids[2],'price_now'=>'0.00','time_now'=>'161427','u_name_now'=>'abc','state'=>'1','bidDisabled'=>'0');
$arr[]=array('id'=>$ids[3],'price_now'=>'0.00','time_now'=>'161427','u_name_now'=>'abc','state'=>'1','bidDisabled'=>'0');
$arr[]=array('id'=>$ids[4],'price_now'=>'0.00','time_now'=>'161427','u_name_now'=>'abc','state'=>'1','bidDisabled'=>'0');
$jarr=json_encode($arr);
echo $jarr;
?>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多