show active

JavaScript related questions should go here.
Post Reply
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

show active

Post by ashwood »

my ajax form goes slow sometimes and fast sometimes.. and when i open my website say the form was to run slow i dont want the user to think the textbox isn't clearing therefore the data isn't working.. and some people they click and click and i dont want 100 of the same thing in my database so i was wondering if i could add something to my ajax code that will show a image when the form is working so they no something is happening.. instead of thinking its not and clicking 100 times..
I would put a signature.. BUT, i don't have the time.
Torniquet
Posts: 52
Joined: Sun Jun 19, 2011 8:10 am
Contact:

Re: show active

Post by Torniquet »

very simply

easiest way of doing this is creating a loading image next to your submit button and having the display as hidden.

[syntax=xhtml]
<input type="submit" class="js_button" /><img src="to/loading/image.gif" style="display:hidden" class="js_loading" />
[/syntax]

once the submit button is clicked, show the image until the request is complete. You can also hide the submit button if you like aswell.

[syntax=javascript]
$('.js_button').click(function(){
$('.js_loading').show();
$('.js_button').hide();
$.ajax({
type: 'post',
url: 'url.php',
data: {'member' : id, 'message':message},
success: function(){
$('.js_button').show();
$('.js_loading').hide();
}
});
});
[/syntax]
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: show active

Post by ashwood »

how would i add this to my code i have.. the ajax post u have replied to before..?
I would put a signature.. BUT, i don't have the time.
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: show active

Post by ashwood »

ashwood wrote:how would i add this to my code i have.. the ajax post u have replied to before..?



could i put where we put the val thing could i also put $('div').show but how would i get it to go away once the request is done..? beca\use i only want it to show whilst the process is being done..
I would put a signature.. BUT, i don't have the time.
ashwood
Posts: 144
Joined: Thu May 12, 2011 7:17 am

Re: show active

Post by ashwood »

SOLVED :) thanks :)
I would put a signature.. BUT, i don't have the time.
Torniquet
Posts: 52
Joined: Sun Jun 19, 2011 8:10 am
Contact:

Re: show active

Post by Torniquet »

lol no prob.

my advise is reference all elements by a class name prefixed with something standard. i always use js_whatever. I know then that the class and element are for certain things.

the bonus is you can use multiple classes, so you can still style via class and use jquery call references.
Post Reply