Web Design Forum: Jquery Ajax Call, Duping? - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Jquery Ajax Call, Duping?

#1 User is offline   bocaj 

  • Retired
  • PipPipPipPipPip
  • View gallery
  • Group: Members
  • Posts: 3,402
  • Joined: 11-January 09
  • Reputation: 99
  • Gender:Male
  • Location:New Sarum
  • Experience:Web Guru
  • Area of Expertise:Entrepreneur

Posted 10 April 2009 - 04:03 AM

Ok, i have this which loads external static content in, adjusts the hash value and i'm using a jquery history plugin link to maintain the functionality of the back/forward buttons, it works in all the browsers i've tested apart from ie7 and opera (you need to press back twice to actually go back). Using firebug, i've determined that every time a one of the nav links are clicked, it's sending two page request, which is what i'm assuming is causing the problem in ie7 and opera.

The code i've got is as follows, i know it's more difficult but i haven't got a live example, i'll try and get one up though for now if i can.

 $(document).ready(function() {   
	function showNewContent() {
		$("div.span-15").slideDown();
		$('#load').fadeOut();   
	}   
	function pageload(hash) {
		if(hash) {
			$("div.span-15").load(hash + " div.span-15",'',function(){
				if($('img:last',this).get(0)) {
					$('img:last',this).load(function(){
						showNewContent();
					});
				} else {
					showNewContent();
				}
			});
		} else {
			$("div.span-15").load("index.html div.span-15");
		}
	}
	$.historyInit(pageload);	
	$('ul.service-nav li a').click(function(){
		var hash = $(this).attr('href');
		hash = hash.replace(/^.*#/, '');
		$("div.span-15").slideUp(300,function(){
			$.historyLoad(hash);
		});
		if(!$('#load').get(0)) {
			$('#wrapper').append('<img src="/images/global/loading.gif" class="loading center" />');
		}
		$('#load').fadeIn('normal');
		return false;
	
	});

});


anyone got any idea's why this is occurring? 'cus i'm just stumped :unknw:
0

#2 User is offline   rosiesp 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 290
  • Joined: 17-November 08
  • Reputation: 1
  • Gender:Male
  • Location:lundn
  • Experience:Intermediate
  • Area of Expertise:Web Designer

Posted 10 April 2009 - 07:04 AM

function pageload(hash) {
if(hash) {
$("div.span-15").load(hash + " div.span-15",'',function(){
if($('img:last',this).get(0)) {
$('img:last',this).load(function(){
showNewContent();
});
} else {
showNewContent();
}
});
} else {
$("div.span-15").load("index.html div.span-15");
}
}

the pageload function uses load() twice, highlighted in red. Is that right?
0

#3 User is offline   bocaj 

  • Retired
  • PipPipPipPipPip
  • View gallery
  • Group: Members
  • Posts: 3,402
  • Joined: 11-January 09
  • Reputation: 99
  • Gender:Male
  • Location:New Sarum
  • Experience:Web Guru
  • Area of Expertise:Entrepreneur

Posted 11 April 2009 - 01:55 AM

yeah, removing it doesn't make a difference anyway, so it's not the cause of the problem.
0

#4 User is offline   bocaj 

  • Retired
  • PipPipPipPipPip
  • View gallery
  • Group: Members
  • Posts: 3,402
  • Joined: 11-January 09
  • Reputation: 99
  • Gender:Male
  • Location:New Sarum
  • Experience:Web Guru
  • Area of Expertise:Entrepreneur

Posted 11 April 2009 - 02:05 AM

ok, bizzare, took a stab in the dark and changed from using a class name, to using and id, and it works fine now, and the history plugin works in all browsers.

I've checked and that class name isn't called twice on the same page? So dunno what happened? :'/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users