javascript - How to use jquery.load to retrieve a part of an html/ or a full html? -
i'm trying load entire/partial html using jquery's load function. i'm aware can done using $.ajax() want learn how use different functions of jquery.
here's current code:
<ul> <li><a id="home" href="#">home</a></li> <li><a id="contact" href="#">contact</a></li> <li><a id="gallery" href="#">gallery</a></li> </ul> <div id="result"> </div> <script> $(document).ready(function(e) { $("#gallery").click(function(e){ $('#result').load('gallery.html'); e.preventdefault(); }); }); </script> currently it's not working , i'm getting 
xmlhttprequest cannot load file:///c:/users/randel/desktop/cis/gallery.html. origin null not allowed access-control-allow-origin.
jquery can't retrieve files filesystem. have move project web server or local development server xampp or similar
other code should work. remember put e.preventdefault() before else:
$("#gallery").click(function(e){ e.preventdefault(); $('#result').load('gallery.html'); });
Comments
Post a Comment