So, I have this code but it doesn't load all of the time. Why?
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(function() {
$("#header").load("/components/navbar.html");
$("#footer").load("/components/footer.html");
});
</script>
</head>
<body>
<div id="header"></div>
Here's the source code: https://glitch.com/edit/#!/sargentcoding-official?path=testindex.html%3A45%3A27
Here's the standard page structure:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta title="Sargent Coding" />
<meta charset="utf-8" />
<meta property="og:title" content="Sargent Coding" />
<meta property="og:site_name" content="Sargent Coding" />
<meta property="og:description" content="Where ambition comes to life." />
<meta
property="og:image"
content="https://cdn.glitch.com/5f5ab845-2cb8-4210-b34a-03b1f032163a%2FScratch%20Stuff%20(77)-svg.svg?v=1607718360358"
/>
<meta property="og:image:width" content="500" />
<meta property="og:image:height" content="500" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title id="titleHtml">Sargent Coding</title>
<link
rel="icon"
type="image/png"
href="https://cdn.glitch.com/5f5ab845-2cb8-4210-b34a-03b1f032163a%2F1a81804e-7a4e-4dd6-9c14-43a2bdb9061b_favicon.png?v=1607718475017"
/>
<link
href="https://fonts.googleapis.com/css2?family=Overpass+Mono"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="/style.css" />
<script
src="https://twemoji.maxcdn.com/v/latest/twemoji.min.js"
crossorigin="anonymous"
></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(function() {
$("#header").load("/components/navbar.html");
$("#footer").load("/components/footer.html");
});
</script>
</head>
<body>
<div id="header"></div>
<!-- Header above. -->
<!-- CODE GOES HERE -->
<!-- Footer below. -->
<div id="footer"></div>
</body>
</html>
I'm not using jQuery for any reason. I just don't know what I'm doing.
question from:
https://stackoverflow.com/questions/65833020/script-tag-doesnt-load-all-of-the-time 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…