jQuery适用于Chrome但不适用于IE(Edge)

时间:2015-08-25 17:35:10

标签: php jquery google-chrome html-lists partial-page-refresh

HTML code:

<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上运行?谢谢你的回答。

1 个答案:

答案 0 :(得分:0)

我没有得到如何编辑我的问题所以我只是把loadLawArticle()放在这里:

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();

}

并且Ima也在php和html中做了一些更改:将ul移动到html。但仍然无法在IE(Edge)上工作并且完全适用于Chrome和Firefox

相关问题