可能重复:
script not working in Ajax returned valueAjax代码在IE.But罚款不工作中的所有其他浏览器
我使用AJAX用于获取一些data.There是一个链接“查看项目这个用户“。同时登录它会调用一个带有参数'userid'的函数'callfunc'。这个ajax函数会去getdetails.php,并且会获取相应用户的一些细节。
<tr><td colspan="6" align="right"><a href="javascript:callfunc(<?= $row5[user_id]; ?>)" style="font-size:10px;">Show items of this user</a></td></tr>
<script type="text/javascript">
function callfunc(str)
{
//alert(str);
if (str.length==0)
{
document.getElementById("result").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getdetails.php?cid="+str,true);
xmlhttp.send();
}
getdetails.php
<?php
require 'include/connect.php';
$cid=$_GET['cid'];
$sql="select * from table where status='Active' and user_id=$cid";
$res=mysql_query($sql);
$tot=mysql_num_rows($res);
if($tot>0){
while($row=mysql_fetch_array($res))
{
echo '<tr class="detail9txt" height="30">
<td width="2%"><input type="checkbox" name="item" id="item" value="'.$row[item_id].'"></td>
<td align="center" width="12%" style="vertical-align:baseline;">
<a href="detail.php?item_id='.$row[item_id].'" id="link3">'.$row['title'].'</a>
</td>
<td align="center" width="17%" style="vertical-align:baseline;">
'.substr($row['des'], 0, 20).'
</td></tr>';
}
?>
此代码是在Mozilla,Chrome的正常工作,并在opera.But不IE.While工作单击“该用户的显示项目”的链接没有任何反应在IE.Any的想法?
你应该开始使用JavaScript库,例如jQuery的** ** –
[**请,请不要在新代码中使用'mysql_ *'函数**](http://stackoverflow.com/a/14110189/1723893)。他们不再被维护[并被正式弃用](https://wiki.php.net/rfc/mysql_deprecation)。看到[**红框**](http://j.mp/Te9zIL)?学习[*准备的语句*](http://j.mp/T9hLWi),并使用[PDO](http://php.net/pdo)或[MySQLi](http://php.net/ mysqli) - [这篇文章](http://j.mp/QEx8IB)将帮助你决定哪个。如果你选择PDO,[这里是一个很好的教程](http://j.mp/PoWehJ)。 –
你是一个bot @NullPointer吗?每次有人使用ext:mysql时,您都是复制意大利面... –