Reputation:
iam trying to show wait message while data is being fetched from database. iam using ajax to fetch the data. the message is already showing but it will disappear quickly. how can i increase the time gap for wait message ,that is the user can view the messge for atleast 4 seconds. Please helps...
<input onchange="mail()" class="span6 m-wrap" type="text" value="" name="mail_id" type="text" id="mail_id" placeholder="Type your mail" />
<div id="loader" style="display:none;">please wait</div>
function mail()
{
var Email=$('#mail_id').val();
$.ajax({
url: "<?echo base_url()?>mailsetr/mail_fetch",
dataType: "json",
type: "POST",
data: {Email:Email},
success: function (res) {
var status = res.user_status;
var name = res.user_name;
var id = res.user_id;
if(status == 1)
{
document.getElementById("name").value =name ;
document.getElementById("id").value =id ;
}
else
{
document.getElementById("name").value ='';
document.getElementById("id").value ='';
}
$('#loader').hide();
},
beforeSend: function ()
{
$('#loader').show();
}
});
}
Upvotes: 0
Views: 25
Reputation: 38642
In Success function use this
$("#loader").fadeOut("3000");
}, 3000);
remove this
beforeSend: function ()
{
$('#loader').show();
}
and paste $('#loader').show();
after $.ajax({
Upvotes: 1