HTML代码:
<h1>LAW<span class="refresh" id="idSpanRefreshLexTitle">REFRESH</span></h1>
<div id="divRefreshLexTitle"><?php lexTitles($conn);?></div>
PHP代码:function lexTitles($conn){
$aql = "SELECT * FROM Articles WHERE AritclesSection = 'LAW' ORDER BY RAND() LIMIT 5";
$result = mysql_query($aql, $conn);
while($row = mysql_fetch_array($result)){
echo "<ul class='law_titles' id='ul_lex_titles'><li><span style='cursor:pointer' onClick='"loadLawArticle('article', '_ajax/lawarticle.php?n=".$row['ArticlesID']."')'">".$row['ArticlesTitle']."</span></li></ul>";
}
}
jQuery $(document).ready(function(){
$('#idSpanRefreshLexTitle').click(function(){
$('#divRefreshLexTitle').load('#divRefreshLexTitle ul#ul_lex_titles');
})
})
我通过PHP创建5 li
,然后尝试刷新它点击span。为什么这工作在Chrome和不工作在IE/Edge?谢谢你的回答。
我不知道如何编辑我的问题所以我只在这里输入loadlawartile ():
function loadLawArticle(thediv, thefile){
var xmlhttp;
if(window.XMLHttpRequest){
xmlhttp = new XMLHttpRequest();
}else{
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
document.getElementById(thediv).innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open('GET', thefile, true);
xmlhttp.send();
}
和我也做了一些改变php和html:移动ul到html。但仍然不能在IE (Edge)上运行,在Chrome和Firefox上运行良好