I want to display success message for 5 seconds it displaying "wait" message but it not displaying "sent" message. I tried a lot but I failed. can you please help me? why my sent message is not displaying?
my timeout function is working but it executing hide 'Loading' line before finishing setTimeout function. HTML code:
<div class="loading" style="display:none">
<h3 style="color:#000;font-size:24px;width:500px"><span id="wait">Please wait...</span><span id="sent" style="display:none">E-mail is sent</span><span id="error" style="display:none">Sorry Please try again</span></h3>
<div class="l_main">
<div class="circle"></div>
<div class="quater">
<span class="top"></span>
<span class="bottom"></span>
</div>
</div>
</div>
jQuery Code:
$('.loading').show();
$("#wait").show();
$.post(base_url+"index.php/myad/getphonenumber",{uniqueid:id,emailaddress:cemail},function(){
$("#wait").hide();
$("#sent").show();
setTimeout(function(){
$("#sent").hide()
}, 5000);
$('.loading').hide();
})
答案 0 :(得分:1)
$('.loading').show();
$("#wait").show();
$.post(base_url+"index.php/myad/getphonenumber",{uniqueid:id,emailaddress:cemail},function(){
$("#wait").hide();
$("#sent").show();
setTimeout(function(){
$("#sent").hide();
$('.loading').hide()
}, 5000);
})
答案 1 :(得分:1)
在.hide()
.loading
setTimeout(function() {
$(".loading").hide()
}, 5000);
jsfiddle https://jsfiddle.net/9fvLtm5r/1/