I used this code as an easy example to grab the content of another HTML file and put it in a div
, whenever I click the link. It works great in Firefox and Safari, but not in Chrome, IE or Opera.
<a class="ajaxLink" href="RS.html">Click to load RS content</a>
<div id="page">
Initial TEXT - will be substituted with RS when clicking ajaxLink
</div>
<script>
$(function () {
$('a.ajaxLink').click(function(e) {
e.preventDefault();
$('#page').load($(this).attr('href'));
});
});
</script>
In Chrome, IE & Opera, whenever I click the link, nothing happens, independent of the content of the HTML file. Might it be my code is not compatible?
To be honest, I got this code from here: Javascript wont load into ajax div
I do not fully understand how the ($(this).attr('href'));
works, but understood that it should be correct to load the HTML in #page
.