I am trying to use Jquery to load html code into another html file, using Jquery's the .load()
method.
I have tried using an absolute path to access the file but I am still getting the same error. I have also tried navigating to absolute path and the file and it will open with no problem in a browser so it dose not appear to be an accesses issue. I have also mapped to the latest version of jQuery instead of my local version.
The error response is unidentified which is making this problem harder to solve:
Updated Code: made changes to code from user recomendations.
Main HTML Page
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#test").load("/menu.html", function(response, status) {
if(status === 'error') {
alert("Failed to load menu.html");
}
else {
alert("Success!");
}
});
});
</script>
</head>
</head>
<body>
<div id="test"></div>
</body>
Loading HTML Page
<ul>
<li><a href="index.html">Home</a></li>
<li>
<a href="article.html">Article</a>
<div class="uk-navbar-dropdown">
<ul class="uk-nav uk-navbar-dropdown-nav">
<li><a href="article.html">Scrollspy</a></li>
<li><a href="article-narrow.html">Narrow</a></li>
</ul>
</div>
</li>
<li><a href="faq.html">Faq</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="components.html">Components</a></li>
</ul>
If any one has any input or has run into a similar error please let me know.
`.
– Bram Verstraten Jun 24 '19 at 22:41