May
18

How To: Create dynamic Content Loading using Ajax and jQuery

Author ZeeShaN    Category AJAX, CSS, JQuery, PHP, Web Development     Tags


.

Create simple ajax base page loading using jQuery fadeIn effects. Put some awesome styles to your web pages using ajax base content loading. Demo and code available.

Table Structure:

CREATE TABLE `data` (
  `id` int(11) NOT NULL auto_increment,
  `full_text` text NOT NULL,
  `page_name` varchar(50) NOT NULL,
  `heading` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
)

jQuery Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$(document).ready(function(){	
		$('.super').click(function(){
			$('#container').fadeOut();
			var a = $(this).attr('id');
			$.post("ajax_page.php?id="+a, {
			}, function(response){
				//$('#container').html(unescape(response));
				///$('#container').fadeIn();
				setTimeout("finishAjax('container', '"+escape(response)+"')", 400);
			});
		});	
	});	
	function finishAjax(id, response){
	  $('#'+id).html(unescape(response));
	  $('#'+id).fadeIn();
	}

HTML

1
2
3
4
5
6
7
<input type="button" name="test" class="super red button" id="1" value="Home" />
<br />
<input type="button" name="test" class="super buy button" id="2" value="About" />
<br />
<input type="button" name="test" class="super green button" id="3" value="Services" />
 
<div id="container"></div>

Add To Facebook Stumble This Digg This Add To Del.icio.us Add To Reddit Add To Yahoo Add To Twitter


Written by ZeeShaN

ZeeShaN RasooL is a web developer who loves to work in latest technologies to create more interactive dynamic and beautiful web pages.







Enter your Email:

Click Here for Popular

Who I Am

Zeeshan Rasool

Software Engineer - PHP
Lahore - Pakistan

zeeshan(@)99points.info
Skype: zeeshan-rasool
gTalk: zishan.rasool85

Categories

Tags

Comments