html - Loading an external .htm file to a div with javascript -
possible duplicate:
loading external .htm javascript div
loading external .htm file div javascript
this entire code:
<html> <head> </head> <body> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(function(){ $('.ajax') .click(function(e){ e.preventdefault() $('#content').load( 'file.htm' ) }) }) </script> <div id="content"> <p>random text</p> </div> <div><a href="#" class="ajax">link</a></div> </body> </html>
the code works fine loading external file div in firefox, nothing happens in chrome , ie, when click link. advice ?
while it's not cause of problem, it's practice use semicolons:
$(function(){ $('.ajax') .click(function(e){ e.preventdefault(); $('#content').load( 'file.htm' ); }); });
you'll hit strange errors if don't.
Comments
Post a Comment