javascript - Ajax not working. I need the header and footer not to reload every time. Can you help me? -


i need header , footer not change in webpages simple ajax code have copied stackoverflow.com. not working. please me.

<html>     <head>         <script src="//code.jquery.com/jquery-1.10.2.js"></script>         <script type="text/javascript">             $(document).ready(function(){                 $("#activities").click(function(){                     $("#body").load("activities.html");                 });             });         </script>     </head>     <body>         <div id="header">             <a href="#" id="#activities">activities</a>             header.         </div>         <div id="body">             <p>                 body.              <p>         </div>         <div id="footer">              footer.          </div>     </body> </html> 

you need change

<a href="#" id="#activities">activities</a> 

to

<a href="#" id="activities">activities</a> <!.............^.......................--> 

note : character "#" not allowed in value of attribute "id"

then add e.preventdefault() prevent browser default action on click event

$(document).ready(function() {     $("#activities").click(function(e) {         e.preventdefault();         $("#body").load("activities.html");     }); }); 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -