Posted By

cemundo on 06/28/11


Tagged

ajax


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jillella
spee66


ajax jQuery


 / Published in: jQuery
 

URL: http://www.bennadel.com/resources/presentations/jquery/demo21/index.htm

  1. $(
  2. function(){
  3. // Get a reference to the content div (into which we will load content).
  4. var jContent = $( "#content" );
  5.  
  6. // Hook up link click events to load content.
  7. $( "a" ).click(
  8. function( objEvent ){
  9. var jLink = $( this );
  10.  
  11. // Clear status list.
  12. $( "#ajax-status" ).empty();
  13.  
  14. // Launch AJAX request.
  15. $.ajax(
  16. {
  17. // The link we are accessing.
  18. url: jLink.attr( "href" ),
  19.  
  20. // The type of request.
  21. type: "get",
  22.  
  23. // The type of data that is getting returned.
  24. dataType: "html",
  25.  
  26. error: function(){
  27. ShowStatus( "AJAX - error()" );
  28.  
  29. // Load the content in to the page.
  30. jContent.html( "<p>Page Not Found!!</p>" );
  31. },
  32.  
  33. beforeSend: function(){
  34. ShowStatus( "AJAX - beforeSend()" );
  35. },
  36.  
  37. complete: function(){
  38. ShowStatus( "AJAX - complete()" );
  39. },
  40.  
  41. success: function( strData ){
  42. ShowStatus( "AJAX - success()" );
  43.  
  44. // Load the content in to the page.
  45. jContent.html( strData );
  46. }
  47. }
  48. );
  49.  
  50. // Prevent default click.
  51. return( false );
  52. }
  53. );
  54.  
  55. }
  56. );

Report this snippet  

You need to login to post a comment.