您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

ajax返回数组,页面接收不到数据

2025/9/18 11:38:30发布25次查看
后端代码
$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
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product