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 12-23-2009, 09:09 AM   PM User | #1
scottrichardson
New to the CF scene

 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
scottrichardson is an unknown quantity at this point
Question 2 AJAX calls affecting 1 loading graphic - How to stop?

Hi all,

I'm fairly new to posting for help on coding, so please bare with me, hope this makes sense!.

See here: http://www.retainingsolutions.com.au/test

You will see two forms on the page at the top. One is a subscribe form, the other is a real time 'apple-style' search engine.

On their own, each feature works perfectly. In fact, they both work perfectly, however the search feature is affecting the subscription form.

The subscription form uses an ajax submit using the jquery form plugin. While it's submitting, it displays a loading graphic in a div. It appears that this loading graphic starts up on ANY ajax call on the page - because when you start typing in the search field, it initiates the newsletter subscription loading sequence.

Given my limited knowledge of how to customise this, I would be ever so thankful if someone could take a quick look at the following codes.

First, here's the jquery script that handles the subscription form, you can see the top section is the ajax loading graphic handler. What I need to do is somehow modify it so it plays ONLY when the newsletter subscription ajax call is happening, and not when ANY other ajax call happens. Is there a way to make this function specific rather than global?

Code:
// form validation and ajax submitter.
jQuery(function() {
		// show a simple loading indicator
		var loader2 = jQuery('<div id="loader2"><img src="images/contact/loader.gif" alt="loading..." /></div>')
			.css({position: "relative", top: "0px", left: "0px"})
			.appendTo("#subscribeConfirmation")
			.hide();
		jQuery().ajaxStart(function() {
			loader2.show();
			$('div#newsletterBox').fadeOut();
		}).ajaxStop(function() {
			loader2.hide();
		}).ajaxError(function(a, b, e) {
			throw e;
		});
		
		var v = jQuery("#subscribeForm").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit({
					target: "#subscribeConfirmation"
				});
			}
		});
	});
Put simply, I don't want the loading graphic for the subscribe form to be initiated when a user is typing in the search field.

Appreciate anyone's time who looks at this.

Kind Regards

Scott
scottrichardson is offline   Reply With Quote
Old 12-30-2009, 10:20 AM   PM User | #2
scottrichardson
New to the CF scene

 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
scottrichardson is an unknown quantity at this point
Wondering if anyone here could possibly help me out? It's the final thing I need to fix on the site so it's finished!

Many thanks,

Scott
scottrichardson is offline   Reply With Quote
Old 12-30-2009, 11:12 AM   PM User | #3
vineet
Regular Coder

 
Join Date: Jun 2008
Posts: 173
Thanks: 2
Thanked 9 Times in 9 Posts
vineet is an unknown quantity at this point
Quote:
Originally Posted by scottrichardson View Post
Wondering if anyone here could possibly help me out? It's the final thing I need to fix on the site so it's finished!

Many thanks,

Scott
just a suggestion, i think its jquery problem and you can ask the moderator to shift your thread in jquery section.

may be you will get some answer there.

vineet
vineet is offline   Reply With Quote
Old 12-30-2009, 02:38 PM   PM User | #4
scottrichardson
New to the CF scene

 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
scottrichardson is an unknown quantity at this point
Oh snap, thanks mate. I'll get them to move it!

Cheers,
scottrichardson is offline   Reply With Quote
Old 12-30-2009, 03:57 PM   PM User | #5
seco
Regular Coder

 
seco's Avatar
 
Join Date: Nov 2008
Location: Oregon
Posts: 682
Thanks: 5
Thanked 79 Times in 77 Posts
seco has a little shameless behaviour in the past
well i see the loader div in the newsletter div....
seco is offline   Reply With Quote
Old 12-30-2009, 10:24 PM   PM User | #6
scottrichardson
New to the CF scene

 
Join Date: Dec 2009
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
scottrichardson is an unknown quantity at this point
Hi there,

Yes thats correct. It is MEANT to be there... however, when using the search, it also activates the loader div and its related javascript function. I don't want my search box making the loader div appearing.

Is there a way to make that ajax loading div function ONLY appear when using the newsletter subscribe?

Cheers,
scottrichardson is offline   Reply With Quote
Reply

Bookmarks

Tags
loading

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:40 PM.


Advertisement
Log in to turn off these ads.