-2

HTML code:

<h1>LAW<span class="refresh" id="idSpanRefreshLexTitle">REFRESH</span></h1>
<div id="divRefreshLexTitle"><?php lexTitles($conn);?></div>

PHP code:

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');
})
})

I'am creating 5 li via PHP, then trying to refresh it clicking on span. Why this works on Chrome and do not work on IE/Edge? Thanks for answer.

αƞjiβ
  • 3,056
  • 14
  • 58
  • 95
Boonkers
  • 1
  • 1
  • 1
    loadLawArticle isn't defined. Either you didn't include all the code, or you didn't make the function. – Parker Aug 25 '15 at 17:39
  • If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Aug 25 '15 at 18:01
  • Thanks for the tip, Jay. Ima gonna to look on it. Keep in touch. – Boonkers Aug 25 '15 at 20:27
  • Nice tut on PDO, Jay. Thanks! – Boonkers Aug 25 '15 at 21:41

1 Answers1

0

Ima didn't get how to edit my question so I just put loadLawArticle() here:

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

}

And Ima also made some changes in php and html: moved ul to html. But still doesn't work on IE (Edge) and perfectly working on Chrome and Firefox

Boonkers
  • 1
  • 1