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 enter image description here

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

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

c++ - Accessing inactive union member and undefined behavior? -

php - Get uncommon values from two or more arrays -