-2

I have two identical HTML files (below) containing JavaScript to load HTML from separate files into divs. HTML file A works fine. HTML file B, however, does not work. I get the following errors while inspecting file B:

jquery-1.10.2.js:1 Uncaught SyntaxError: Invalid or unexpected token
working2.html:13 Uncaught ReferenceError: $ is not defined
    at working2.html:13
(anonymous) @ working2.html:13
working2.html:18 Uncaught ReferenceError: $ is not defined
    at working2.html:18
(anonymous) @ working2.html:1

The issue is experienced in Firefox and Chrome while the website is running on IIS. I'm hoping it's just something simple that I'm missing, as I'm new to JavaScript. Any help is appreciated!

File A (working):

<head>
    <title>Switch Maps</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <!-- Sorting Javascript script from: https://www.kryogenix.org/code/browser/sorttable/ -->
    <script src="./Scripts/sorttable.js"></script>
    <!--JS from https://stackoverflow.com/a/42333464 -->
    <script src="./Scripts/jquery-1.10.2.js"></script>
</head>

<body id="Switch_Maps">
  <!--Nav bar (code modified from https://stackoverflow.com/a/42333464)-->
  <div id="nav-placeholder"></div>
  <script>$(function(){$("#nav-placeholder").load("./page_elements/side-bar.html");});</script>
  <!--end of Navigation bar-->

  <!--Footer (code modified from https://stackoverflow.com/a/42333464)-->
  <div id="foot-placeholder"></div>
  <script>$(function(){$("#foot-placeholder").load("./page_elements/foot.html");});</script>
  <!--end of Footer-->
</body>

File B (not working):

<head>
  <title>Switch Maps</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
  <!-- Sorting Javascript script from: https://www.kryogenix.org/code/browser/sorttable/ -->
  <script src="./Scripts/sorttable.js"></script>
  <!--JS from https://stackoverflow.com/a/42333464 -->
  <script src="./Scripts/jquery-1.10.2.js"></script>
</head>

<body id="Switch_Maps">
<!--Nav bar (code modified from https://stackoverflow.com/a/42333464)-->
<div id="nav-placeholder"></div>
<script>$(function(){$("#nav-placeholder").load("./page_elements/side-bar.html");});</script>
<!--end of Navigation bar-->

<!--Footer (code modified from https://stackoverflow.com/a/42333464)-->
<div id="foot-placeholder"></div>
<script>$(function(){$("#foot-placeholder").load("./page_elements/foot.html");});</script>
<!--end of Footer-->
</body>

Thanks in advance for any help possible!

Edit: The answers here: JQuery - $ is not defined do not resolve the issue for me.

gitClaus
  • 3
  • 2

1 Answers1

0

If you can switch the filenames and the original file A still works, the only possible reason is that your files aren't identical after all. You should use a binary diffing tool to confirm that.

FINDarkside
  • 2,102
  • 1
  • 18
  • 26