Advertisement
Guest User

Untitled

a guest
Mar 15th, 2011
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //run on page load
  2. $(function(){  
  3.     //bind a click event to the nav links
  4.     $("#nav a").bind("click", function(e){
  5.  
  6.         //keep the links from going to another page by preventing their default behavior
  7.         e.preventDefault();
  8.  
  9.         //this = link; grab the url
  10.         var pageLocation = this.href;
  11.  
  12.         //fire off an ajax request
  13.         $.ajax({
  14.             url: pageLocation,
  15.        
  16.         //passing data
  17.         data: { foo: "bar", something: "else" },
  18.  
  19.         //defining transport method (it's GET by default anyway, but you could change to post or whatever's relevant)
  20.         type: "GET",
  21.  
  22.             //on success, set the html to the responsetext
  23.             success: function(data){
  24.                 $("#content").html(data.responseText);
  25.             }
  26.         });
  27.     });
  28. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement