$.ajax() jQuery AJAX Demo

$.ajax() jQuery AJAX Demo

AboutContactOfficeError

Click on the above links to load content.

 

$(
	function(){
		// Get a reference to the content div (into which we will load content).
		var jContent = $( "#content" );

		// Hook up link click events to load content.
		$( "a" ).click(
			function( objEvent ){
				var jLink = $( this );

				// Clear status list.
				$( "#ajax-status" ).empty();

				// Launch AJAX request.
				$.ajax(
					{
						// The link we are accessing.
						url: jLink.attr( "href" ),

						// The type of request.
						type: "get",

						// The type of data that is getting returned.
						dataType: "html",

						error: function(){
							ShowStatus( "AJAX - error()" );

							// Load the content in to the page.
							jContent.html( "<p>Page Not Found!!</p>" );
						},

						beforeSend: function(){
							ShowStatus( "AJAX - beforeSend()" );
						},

						complete: function(){
							ShowStatus( "AJAX - complete()" );
						},

						success: function( strData ){
							ShowStatus( "AJAX - success()" );

							// Load the content in to the page.
							jContent.html( strData );
						}
					}							
					);

				// Prevent default click.
				return( false );					
			}
			);

	}
	);
Advertisements
By Rz Rasel Posted in jQuery

One comment on “$.ajax() jQuery AJAX Demo

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s