execute a function after redirecting – javascript

If you don’t want to or can’t re-code your page to support AJAX, the other old-school option is to pass a parameter in the URL as a hint to the refreshed page. (You can hide it by making the redirect a POST if you feel it’s really necessary, or use a cookie technique. The point is that the refreshed page needs a token of some form from the prior page.)

eg:

$('#fav').click(function(){
    window.location = 'production/produc_order.php?create=1';
})

and put the fade code inside the $(document).ready() function, with a check for the create parameter, cookie or whatever.

I’ll agree with @remibreton though, using AJAX is the more hip, modern method.

Leave a Comment