tags:

views:

56

answers:

4

hey guys, i know this question might be too easy, but i have no idea how to solve this.

when submitting a form i'll fadeIn a Loading-Image. When submitting the form was a success the page redirects blabla...

Now when I hit the BACK Button in my browser and i visit the previous page with the form the Loading-Image is still shown.

How can i make that hide again?

regards

A: 

Assuming you're sending this via ajax since you get a loading screen. Just attach the image to hide on success.

$.ajax({
  url: 'ajax/form.html',
  beforeSend: function() {
    $('.loadingImage').fadeIn("slow");
  }
  success: function() {
    $('.loadingImage').fadeOut("fast");
  };
});
Trip
no i'm not using ajax, I'm just using … $("form").submit(function() { $('#spinner').fadeIn('slow');
i thought of using the unload() method, but i'm not really unloading a page. if the form is submitted i'm just showing running through an include!
Hmm I recommed it at least.
Trip
A: 

Why not do something as simple as this?

$(document).ready(function() {
    $('.loadingImage').hide();
});

Just making sure that when your page is loaded your image is hidde.

George Antoniadis
A: 

If you're actually submitting the form, then yes, you're unloading the page.

$(function(){
  $(window).unload(function(){
    $('.loadingImage').hide();
  });
});

That'll hide it before you actually leave the page.

BBonifield
+1  A: 

and what if you do a POST/Redirect/GET, which solves the duplicate form submitting as well?

KARASZI István