Reputation: 188
I am trying an ajax load on page but it not working. It displays some funny errors. I would paste the loader page. content to load and error below.
loader page
<!doctype html>
<html lang=en>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="themes/mobilethem.min.css" />
<link rel="stylesheet" href="themes/mobilethem.css" />
<link rel="stylesheet" href="themes/jquery.mobile-1.1.1.css" />
<script src="themes/js/jquery-1.7.1.min.js"></script>
<script src="themes/js/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function (){
//alert("afdasdf");
$('#load').click(function (){
//alert("asdfsadf");
$('#result').load("load.html");
});
});
</script>
</head>
<body>
<div data-role="header">
<a href="#" id="load"> Load page</div>
</div>
<div data-role="content">
<div id="result"></div>
</div>
<div id="footer">
</div>
</body>
</html>
content to load load.html
This is the content my friend. how do you want to make this happen
Error message in browser console
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. jquery-1.7.1.min.js:3 OPTIONS file:///C:/wamp/www/MyJqueryMobile/load.html No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. jquery-1.7.1.min.js:4 XMLHttpRequest cannot load file:///C:/wamp/www/MyJqueryMobile/load.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. loadpage.html:1
Upvotes: 2
Views: 654
Reputation: 13686
Your going to have to run that from your web server in order for it to work. Otherwise the browser sees you doing a cross site request.
Turn on your WAMP server and go to: http://localhost/MyJqueryMobile/load.html
it should work.
Upvotes: 1