请各位大侠帮我看看这段代码我错在哪里 我从PHP取数据,传到JS执行的时候,发现JS根本都没有执行
php代码<?phperror_reporting(0);mysql_connect(“数据库","username","password")ordie("不能链接到数据...
php代码
<?php
error_reporting(0);
mysql_connect(“数据库","username","password") or die("不能链接到数据库服务器".mysql_error());
mysql_select_db("showslow");
$sql2 = "select a.o from yslow2 a order by a.timestamp desc limit 12";
$query2=mysql_query($sql2);
while ($result2=mysql_fetch_array($query2))
{
$foodsPic[]=$result2[o];
}
$data1 = json_encode($foodsPic);
// echo $data1;
?>
js代码
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script>
$(function()
{
$.ajax({
type:'get',
url:'localhost/g.php',
cache:false,
dataType:'json',
success:function(data1){
alert(data1);
}
});
});
</script> 展开
<?php
error_reporting(0);
mysql_connect(“数据库","username","password") or die("不能链接到数据库服务器".mysql_error());
mysql_select_db("showslow");
$sql2 = "select a.o from yslow2 a order by a.timestamp desc limit 12";
$query2=mysql_query($sql2);
while ($result2=mysql_fetch_array($query2))
{
$foodsPic[]=$result2[o];
}
$data1 = json_encode($foodsPic);
// echo $data1;
?>
js代码
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<script>
$(function()
{
$.ajax({
type:'get',
url:'localhost/g.php',
cache:false,
dataType:'json',
success:function(data1){
alert(data1);
}
});
});
</script> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询