-3

Why is it my ajaxContent not loaded? It was working before I created the text files and the ajax function. Now it cannot be loaded in Chrome or Firefox. What am I doing wrong?

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My website</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> 
<script src="http://code.jquery.com/ui/1.11.0/jquery-ui.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript">
<link rel="stylesheet"
href="http://code.jquery.com/ui/1.10.0/themes/base/jquery-ui.css">

function ajax(url) {
    $("#ajaxContent").load(url);
}

$(document).ready(function() {
    ajax('Aboutus.txt');
});
</script>
</head>
<body>
<div class="wrapper">
<header>
<nav>
<ul>
<li><a href onClick="ajax('Aboutus.txt')">About us</a></li>
<li><a href onClick="ajax('Menu.txt')">Menu</a></li>
<li><a href onClick="ajax('Menu.txt')">Events</a></li>
<li><a href onClick="ajax('Menu.txt')">Gallery</a></li>
<li><a href onClick="ajax('Menu.txt')">Booking</a></li>
<li><a href onClick="ajax('Menu.txt')">Shop</a></li>
<li><a href onClick="ajax('Menu.txt')">Contacts</a></li>
</ul>
</nav>
</header>
<article id="ajaxContent"></article>
<footer>
&copy; 2016
</footer>
</div><!-- .wrapper -->
</body>
</html>

1 Answers1

0

Make sure that you have a web server (IIS or Apache) installed and serving files. mixture of protocols will never give you the desired results.

you are loading all the assets over http or https protocol. you need to load all your html files and css files over http which requires a web server.

have a look at wampserver

Rohit Agre
  • 1,528
  • 1
  • 14
  • 25