Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-17-2012, 08:25 PM   PM User | #1
dingod
New to the CF scene

 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
dingod is an unknown quantity at this point
Ajax problem please help

I hope I'm posting in right spot... first timer...

Here is my problem. I have graphic buttons that should be dynamically loading data into a slider via javascript and ajax. But it's not working and I'm not sure why. The data only loads when I do a page refresh (F5). Won't load when I click a button. I will post code... Help would be greatly appreciated!

First the loader...

Code:
<script type="text/javascript" src="/2012/js/jquery.history.js"></script>
<script type="text/javascript">
    var $j = jQuery.noConflict(); 
	</script>

   	<script type="text/javascript">


	$j(document).ready(function () {


	    $j.history.init(pageload);	
	    
		$j('a[href=' + window.location.hash + ']').addClass('selected');
		
		$j('a[rel=ajaxtwo]').click(function () {
		
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
	 		$j.history.load(hash);	
	 		
	 		$j('a[rel=ajaxtwo]').removeClass('selected');
	 		$j(this).addClass('selected');
	 		$j('#big_slider').hide();
	 		$j('.loading').show();
	 		
			getPage();
	
			return false;
		});	
	});
	
	function pageload(hash) {
		if (hash) getPage();    
	}
		
	function getPage() {
		var data = 'page=' + encodeURIComponent(document.location.hash);
		$j.ajax({
			url: "slider_loader.php",	
			type: "GET",		
			data: data,		
			cache: false,
			success: function (html) {	
				$j('.loading').hide();				
				$j('#slider_area').html(html);
				$j('#big_slider').fadeIn('slow');		
		
			}		
		});
	}

	</script>
HTML Buttons code...

Code:
<div id="slider_area">
<div id="big_slider" class="flexslider">
<ul class="slides">
                <li>work slide 1</li>
                <li>work slide 2</li>

</ul></div></div>
<ul class="tj_gallery">
							<li><a href="#logo1" class="tint" rel="ajaxtwo"><img src="/2012/images/logos/logo_agassiz.jpg" alt="image01" /></a></li>
							<li><a href="#logo2" class="tint" rel="ajaxtwo"><img src="/2012/images/logos/logo_benesserre.jpg" alt="image02" /></a></li>
							<li><a href="#logo3" class="tint" rel="ajaxtwo"><img src="/2012/images/logos/logo_canine.jpg" alt="image03" /></a></li>
							<li><a href="#logo4" class="tint" rel="ajaxtwo"><img src="/2012/images/logos/logo_cbs.jpg" alt="image04" /></a></li></ul>
PHP content switcher

PHP Code:
<?

switch($_GET['page'])  {
    case 
'#logo1' $page '<div id="big_slider" class="flexslider"><ul class="slides">
                <li>test2 test2</li>
                <li>kick2 ass2</li>
</ul></div>'
; break;

    case 
'#logo2' $page '<div id="big_slider" class="flexslider"><ul class="slides">
                <li>test3 test3</li>
                <li>kick3 ass3</li>
</ul></div>'
; break;

    case 
'#logo3' $page '<div id="big_slider" class="flexslider"><ul class="slides">
                <li>test4 test4</li>
                <li>kick4 ass4</li>
</ul></div>'
; break;

    case 
'#logo4' $page '<div id="big_slider" class="flexslider"><ul class="slides">
                <li>test5 test5</li>
                <li>kick5 ass5</li>
</ul></div>'
; break;

}

echo 
$page;
?>
dingod is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:25 AM.


Advertisement
Log in to turn off these ads.