【问题标题】:jQuery works on Chrome but not on IE (Edge)jQuery 适用于 Chrome 但不适用于 IE (Edge)
【发布时间】:2015-08-25 17:35:10
【问题描述】:

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?感谢您的回答。

【问题讨论】:

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


【解决方案1】:

我不知道如何编辑我的问题,所以我把 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 上完美运行

【讨论】:

    猜你喜欢
    • 2019-10-26
    • 2019-11-15
    • 2014-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-03
    • 2013-03-24
    相关资源
    最近更新 更多