Hiya,
Just trying to learn AJAX properly and can’t even get my head around what I think should be something really really simple. I am probably just doing something completely stupid somewhere but can’t for the life of me figure it out.
Some code that I have shown below works just fine when called up as a static page from anywhere on my hard-drive. The JS file is actually located (as you can see from the code) in a localhost folder where I have the web-site being developed using MAMP on OSX. If I use the code shown below outside of EE and just in a static HTML file then it all works fine but as soon as I paste the code exactly as is into a template in EE it will not load the page using AJAX. I have checked the rendered source code from the template and it is exactly the same as the static HTML file which works fine. I’m sure there must be something that I am doing which is dumb here so any help would be greatly appreciated on this one.
The Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>JQuery Tests</title>
$(document).ready(function(){$("a.load-page").click(function(){$("div.load-page-here").load("http://www.google.com");});});
</head>
<body>
<div>Some text</div>
<div class="load-page-here">Replace this</div>
<a href="#" class="load-page">Load Page</a>
</body>
</html>Thanks for any help on this one as I am tearing my hair out thinking what could possibly be different between the two - static file or template rendered by EE?
Best wishes,
Mark