In index.html I load p5:
and use jQuery to load another page on a button click:
<script>
$(document).ready(function(){
$("#btn").click(function(){
$("#contentx").load("content1.html");
});
});
</script>
and it works fine. In content1.html I have (among other things):
<script>
var url = "drawfarm.js";
$.getScript(url);
</script>
to load a script containing the p5 content and I get an error:
"p5.min.js:3 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'appendChild')"
Can someone explain what's going wrong?