Reputation: 4331
I am working on site where i show fancybox for contact us form.i submit form using ajax.on process state i show ajax loading image.On first click it show the image but clicking again image doesn't show.My ajax code is this :
<script type="text/javascript">
function submitForm()
{
jQuery(".ajax-content").show();
var str = jQuery( "form" ).serialize();
jQuery.ajax({
type: "POST",
url: 'myurl',
data: str,
format: "json",
beforeSend: function( xhr ) { alert('hi'); jQuery(".ajax-content").show();},
success: function(data) {
var obj = JSON.parse(data);
if( obj[0] === 'error')
{
jQuery("#error").html(obj[1]);
jQuery(".loading-gif").hide();
}else{
jQuery(".loading-gif").hide();
jQuery("#result").html(obj[1]);
setTimeout(function () {
jQuery.fancybox.close();
}, 2500);
}
}
});
}
</script>
ajax-content
class is that div contains ajax image
Any help or pointing to error will be appreciated.Thanks
Upvotes: 1
Views: 979
Reputation: 2017
I think the image is hidden the second time. Can you try
beforeSend: function( xhr ) {
alert('hi');
jQuery(".loading-gif").show();
jQuery(".ajax-content").show();
},
Upvotes: 1