后端代码
<code>$sql=mysql_query("select number,decode from hongbao order by rand() limit 1 ");$row=mysql_fetch_array($sql);$_SESSION['ip']=$_POST['ip'];$data['number']=$row['number'];$data['decode']=$row['decode'];echo json_encode($data);?></code>
前端代码
<code>$(document).ready(function(){ $(".red").click(function(){ $(this).a<strong style="color:transparent">9来源gaodai#ma#com搞@代~码$网</strong>搞gaodaima代码ddClass("shake"); setTimeout(function(){ $(".red").removeClass("shake"); $.post( "recive.php", {ip:$("#ip").val()}, function(data){ $(".windows").fadeIn(); $("#number").attr("value",dada.number); $("#decode").attr("value",data.decode); $(".opacity").fadeIn(); } ) },2000); }); $(".close").click(function(){$(this).parent().fadeOut();$(".opacity").fadeOut()})});</code>
返回数据那里是不是写错了,求大神分析···
回复内容:
后端代码
<code>$sql=mysql_query("select number,decode from hongbao order by rand() limit 1 ");$row=mysql_fetch_array($sql);$_SESSION['ip']=$_POST['ip'];$data['number']=$row['number'];$data['decode']=$row['decode'];echo json_encode($data);?></code>
前端代码
<code>$(document).ready(function(){ $(".red").click(function(){ $(this).addClass("shake"); setTimeout(function(){ $(".red").removeClass("shake"); $.post( "recive.php", {ip:$("#ip").val()}, function(data){ $(".windows").fadeIn(); $("#number").attr("value",dada.number); $("#decode").attr("value",data.decode); $(".opacity").fadeIn(); } ) },2000); }); $(".close").click(function(){$(this).parent().fadeOut();$(".opacity").fadeOut()})});</code>
返回数据那里是不是写错了,求大神分析···
<code>$data=array();$result=mysql_query("SELECT xx FROM xxoo LIMIT 1");//把结果放进循环中看看while($row=mysql_fetch_array($result)){ array_push($data,array("xx"=>$row['xx'])); //还是不行可能是json的格式不是标准的 //以上的标准的json格式}echo json_encode($data);</code>
怀疑是你的url写错了,是 recive.php 还是 receive.php ?
$.post少了一个参数,设置为 json