I'm trying to run an answer I found at the following link: Asynchronously Load the Contents of a Div
But when I do, I get errors that I don't quite understand.
My code:
$(document).ready(function() {
$("#first").load(function() {
$("body").append($("<div></div>").attr({
id: "second"
}).text("Second"));
$("#second").load(function() {
$("body").append($("<div></div>").attr({
id: "third"
}).text("Third"));
});
});
});
<html>
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-
3.2.1.min.js"></script>
</head>
<body>
<div id="#first">First</div>
</body>
</html>
The error I get back from Chrome is extensive. But here's the highlights:
Uncaught TypeError: a.indexOf is not a function
at r.fn.init.r.fn.load (jquery-3.2.1.min.js:4)
at HTMLDocument.<anonymous> (temp.html:6)
at j (jquery-3.2.1.min.js:2)
at k (jquery-3.2.1.min.js:2)
Any ideas?