$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);?>
前端代码
$(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()})});
返回数据那里是不是写错了,求大神分析···
回复内容: 后端代码
$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);?>
前端代码
$(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()})});
返回数据那里是不是写错了,求大神分析···
$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);
怀疑是你的url写错了,是 recive.php 还是 receive.php ?
$.post少了一个参数,设置为 json
