-1

I'm getting the error "Cannot set property 'innerHTML' of null" with this :

<div id="refresh">Loading ...</div>
<script src="test/js/refresh.js"></script>

refresh.js :

$("#refresh").load("test/ajax/refresh.php");

Why ?

PS: Screenshot of the code, if needed : http://prntscr.com/fpvjuf

And the code : https://hastebin.com/ziqinoyulo.xml

Matt
  • 1
  • 1

2 Answers2

1

Your JavaScript code may be running before the page has loaded. Try this:

$(function() {
    $("#refresh").load("test/ajax/refresh.php");
});
aimorris
  • 436
  • 3
  • 18
0

My refresh.php file was returning document.getElementById("refesh").innerHTML = "Test";

refesh and not refresh, sorry.

Matt
  • 1
  • 1