Basic AJAX load with jQuery


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. $(function()
  3. {
  4. $('#link a').click(function(e) {
  5. var url = $(this).attr('href');
  6. $('#elementToLoadContentInto').load(url);
  7. e.preventDefault();
  8. });
  9. });
  10. </script>
  11.  
  12. HTML:
  13.  
  14. basic list like
  15. <ul>
  16. <li><a href="#" id="link">blabla</a></li>
  17. </ul>
  18. <div id="elementToLoadContentInto">
  19. blablabla
  20. </div>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.