PDA

View Full Version : jquery callback href



ggalan
12-15-2010, 01:38 AM
can anyone lend a hand?
i want to click an image and have jquery:

-hide that image
-then call a href to test.php

this does not seem to work


$("img").click(function () {
$("img").hide(1000,function(){
$.get("test.php");
});
});

ggalan
12-15-2010, 01:53 AM
i found this link
http://curtishenson.com/quick-tip-delay-page-loading-with-jquery/
but i dont see a reference to href

ggalan
12-15-2010, 01:59 AM
maybe something like this?
but this still doesnt work



$('img').click(function(e){
var toLoad = $(this).attr('test.php');
$("img").hide(1000);
setTimeout(function(){window.location = toLoad}, 1000);
e.preventDefault
});

ggalan
12-15-2010, 02:07 AM
got it working like this, but why does that variable not work?


$('img').click(function(e){
$("img").hide(1000);
setTimeout(function(){window.location = 'test.php'}, 1000);
e.preventDefault
});