Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

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 10-10-2012, 04:15 AM   PM User | #1
harryjcourt
New to the CF scene

 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
harryjcourt is an unknown quantity at this point
Ajax request firing multiple times

Hello,

I'm currently in the process of creating a website for a client. One of the pages on the website has a lot of content that is toggled in and out by a menu. The content is loaded using jQuery's load().

Everything is working fine, however the first time you click on the menu (and only the first time), the AJAX request is being sent up to 6 times. This is only on the first use of the menu, all subsequent clicks on the menu correctly only send the AJAX request once.

I have looked at my code a few times and can't see what may be causing this! If anyone has any ideas it would be highly appreciated.

The URL of the page can be found here:

http://demo.slickdesign.com.au/mauri...x.php/services

And the JS code controlling the functionality is shown below (which you can also access by viewing source on the above URL):

Code:
$(document).ready(function() {

$('#services .service').click(function() {
		var targetContent = $(this).attr('rel');
		$('#services .service').removeClass('active').filter(this).addClass('active');
		$('#services .column.first').children(':visible').fadeOut(350, function() {
			$('#services .column.first').html('<img class="ajax-loader" src="http://demo.slickdesign.com.au/mauricemeade/images/interface/loader.gif">');
			$('#services .column.first').load(targetContent, function() {
				$('#services .column.first .loaded-content').fadeIn();	
			});
		});
	});
});
harryjcourt is offline   Reply With Quote
Reply

Bookmarks

Tags
ajax, jquery, load(), multiple requests

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 08:43 AM.


Advertisement
Log in to turn off these ads.