功能checkSession(){ $就({URL: 「session.php文件」,成功:功能(數據){ 如果(數據== 1){ VAR postFilen = 'msg.php'; $ 。 post(postFilen,function(data){(「。msg」).html(data).find(「。message2」)。fadeIn(「slow」) } else { $('。msg')。隱藏();} }}); // setInterval的( 'checkSession()',1000);何處放置超時()淡出?
現在我想將它已被證明在5秒鐘後淡出。味精 我該怎麼辦做到這一點.. 我曾嘗試過:
function checkSession(){
$.ajax({url: "session.php", success: function(data){
if(data == 1){
var postFilen = 'msg.php';
$.post(postFilen, function(data){
$(".msg").html(data).find(".message2").fadeIn("slow")
setTimeout(function() {
$('.msg').fadeOut('slow');
}, 5000);
});
}else{
$('.msg').hide();
}
}});
// setInterval('checkSession()',1000);
}
但隨後第1次後,不會出現該消息..
沒有工作..第一次它淡出同時它要顯示,然後第二個和其餘的時間它沒有出現 – Karem 2010-03-07 09:55:35
正確,父母和延遲倒置。修正了我的例子。 – 2010-03-07 11:30:14
+1很好的使用'delay'。 – 2010-03-07 13:04:11