HTML & CSS:
<a href="#">link</a>
<img src="http://2.bp.blogspot.com/_OIHTbzY7a8I/TOaiTKLqszI/AAAAAAAAAHM/eb3iiOqxzKg/s640/Auto_Audi_Audi_concept_car_005130_.jpg" />
<div></div>
img { display: none; }
a { display: block; }
JS:
$("a").click(function(){
$.ajax({
url: "test.php",
contentType: "html",
beforeSend: function(){
$("img").fadeIn(600, function(){
$("div").append(" | beforeSend finished | ");
});
},
error: function(){
$("div").append(" | error | ");
}
});
return false
});
The problem is, error
function starts, before animation in beforeSend
function finishes.
Here is working example http://jsfiddle.net/H4Jtk/2/
error
should begin to work only when beforeSend
is finished. How to do this?
I use beforeSend
function to start animation of the blocks when ajax starts. I can't remove it.
Thanks.