+ -
当前位置:首页 → 问答吧 → ajax+jquery+php遇到的问题,dataType: "json"无法成功欲行函数

ajax+jquery+php遇到的问题,dataType: "json"无法成功欲行函数

时间:2011-08-12

来源:互联网

这是定时运行的一个代码:
 setInterval(function()
{  
auctionhisid = <?=$obj_pro->id !=""?$obj_pro->id :"";?>;
getStatusUrl3 = "updatehistory.php?aucid_new="+auctionhisid;
$.ajax(
{
url: getStatusUrl3,
dataType: "json",
success: function(data)
{
data1 = eval("(" + data.responseText + ")");
for(i=0;i<data.histories.length;i++)
{
biddingprice = data.histories[i].history.bprice;
biddingusername = data.histories[i].history.username;
biddingtype = data.histories[i].history.bidtype;
document.getElementById("bid_price_" + i).innerHTML = biddingprice;
document.getElementById("bid_user_name_" + i).innerHTML = biddingusername;
document.getElementById("bid_type_" + i).innerHTML = placesinglebid;
}
if(data.myhistories.length)
{
for(j=0;j<data.myhistories.length;j++)
{
biddingprice1 = data.myhistories[j].myhistory.bprice;
biddingusername1 = data.myhistories[j].myhistory.time;
biddingtype1 = data.myhistories[j].myhistory.bidtype;
document.getElementById("my_bid_price_" + j).innerHTML = biddingprice1;
document.getElementById("my_bid_time_" + j).innerHTML = biddingusername1;
("my_bid_type_" + j).innerHTML = placesinglebid;
}
}
document.getElementById("curproductprice").innerHTML = data.histories[0].history.bprice;
},error: function(XMLHttpRequest,textStatus, errorThrown){
//alert(textStatus);
}
});
},1000)
}




这是PHP:updatehistory.php

<?
include("connect.php");

$aucid=$_GET["aucid_new"];
$uid = $_SESSION["usid"];

$qryhis = "select * from bid_account ba left join user_manage r on ba.user_id=r.id where ba.product_id=$aucid order by ba.id desc limit 0,10";
$reshis = mysql_query($qryhis) or die(mysql_error());
$total = mysql_num_rows($reshis);
for($i=1;$i<=$total;$i++)
{
$obj = mysql_fetch_object($reshis);

if($i==1)
{
$temp2 = '{"history":{"bprice":"'.$obj->bidding_price.'","username":"'.$obj->user_name.'","bidtype":"'.$obj->shijian.'"}}';
}
else
{
$temp2 .= ',{"history":{"bprice":"'.$obj->bidding_price.'","username":"'.$obj->user_name.'","bidtype":"'.$obj->shijian.'"}}';
}
}
if($flg!=1)
{
$qryhis1 = "select * from bid_account ba left join user_manage r on ba.user_id=r.id where ba.product_id=$aucid and ba.user_id=$uid order by ba.id desc limit 0,10";

$reshis1 = mysql_query($qryhis1) or die(mysql_error());
$total1 = mysql_num_rows($reshis1);
for($i=1;$i<=$total1;$i++)
{
$obj1 = mysql_fetch_object($reshis1);
if($i==1)
{
$temp21 = '{"myhistory":{"bprice":"'.$obj1->bidding_price.'","time":"'.$obj1->shijian.'","bidtype":"'.$obj1->user_name.'"}}';
}
else
{
$temp21 .= ',{"myhistory":{"bprice":"'.$obj1->bidding_price.'","time":"'.$obj1->shijian.'","bidtype":"'.$obj1->user_name.'"}}';
}
}
}
if($temp2!="")
{
return '{"histories":['.$temp2.'],"myhistories":['.$temp21.']}';
}
else
{
return $temp2;
}


?>


为什么无法运行回调success: function(data)内容呢?现在正在学习这方面内容,望各路高手指点,谢谢了。

作者: davcai   发布时间: 2011-08-12

哎 没有在 还是没有人明白我的意思

作者: davcai   发布时间: 2011-08-12