小弟遇到一難題 求大神幫忙
$rs=mysql_query("select * from title");
$row=mysql_fetch_array($rs);
$num=mysql_num_rows($rs);
//echo $num;
for($i=1;$i<=8;$i++)
{
$rs=mysql_query("select * from title where parent_id=$i");
$row=mysql_fetch_array($rs);
//print_r($row)
?>
" width="160px">
$sql="select * from index_kind where parent_id=$i";
$rs=mysql_query($sql);
while($row=mysql_fetch_array($rs))
{
?>
">
}
?>
" class="spfl_right">
(這是ajax的處理)
require_once 'conn.php';
$child_id=$_GET["id"];
$rs=mysql_query("select * from index_kind where child_id='$child_id'");
$row=mysql_fetch_array($rs);
$nums=mysql_num_rows($rs);
for($i=1;$i<=$nums;$i++)
{
echo $row["good_img"];
}
?>
(這裡是AJAX)
function omo(obj,str)
{
//alert(str);
obj.style.borderBottom="1px solid #e4393c";
//alert(obj.id);
var xmlhttp;
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHttp");
}
xmlhttp.open("get","chuli.php?id="+obj.id,true);
xmlhttp.onreadystatechange=function(){
//alert(xmlhttp.readyState)
if(xmlhttp.readyState==4)
{
alert(xmlhttp.responseText)
document.getElementById(str).innerHTML="";
}
}
xmlhttp.send(null);
}
這是我測試用的資料庫
然後當我移到這個劃紅線的地方是彈出的是圖片的地址
我想讓圖片顯示在下方的黑框裡 但是弄不出來啊 !!! 求大神幫幫忙解決下問題!!!
分享到: 更多
------解決方案--------------------
既然你 document.getElementById(str).innerHTML="";
那麼 xmlhttp.responseText 中就應該是一個合法的圖片路徑
而你 alert(xmlhttp.responseText) 看到的卻是多個,把這多個圖片名當做一個圖片的路徑,無論如何也是不會顯示的