嗨,我一直試圖添加甚至延遲()或setTimeOut這個簡單的發送消息,但我認爲我不明白這是如何工作的,我一直在「包裝」功能,但每次我得到了很多的語法錯誤,如果我「修復」他們我什麼都沒有,但所有行動一個接一個地完成,即使我設置延遲(8000)沒有延遲實際上反映發送Ajax消息setTimeOut行動之間的延遲
這是腳本用於發送消息
$.ajax({
type: "POST",
url: "sendtofriend.php",
data: dataString,
success: function() {
$('#message').css("display", "none");
$('#messagein').css("display", "block");
$('#messagein').html("<div id='messageinin'></div>");
$('#messageinin').html("<h2><%= t('generales.thankks') %></h2>")
.append("<p><%= t('generales.msgsent') %>.</p>")
.fadeIn(1500, function() {
$('#messagein').append("<img id='checkmark' src='images/check.png' />");
});
$('#message').fadeIn(1500, function() {
$('#messagein').css("display", "none");
$('#message').css("display", "block");
});
}
});
return false;
});
});
我已經嘗試了很多東西,像這樣的例子
$.ajax({
type: "POST",
url: "sendtofriend.php",
data: dataString,
success: function() {
$('#message').css("display", "none");
$('#messagein').css("display", "block");
$('#messagein').html("<div id='messageinin'></div>");
$('#messageinin').html("<h2><%= t('generales.thankks') %></h2>")
.append("<p><%= t('generales.msgsent') %>.</p>")
.delay(8000)
.fadeIn(1500, function() {
$('#messagein').append("<img id='checkmark' src='images/check.png' />");
});
$('#message').fadeIn(1500, function() {
$('#messagein').css("display", "none");
$('#message').css("display", "block");
});
}
});
return false;
});
});
我的目標是#message
當確認div'#messagein'可見時消失,然後消除確認並重新提交表單以提交另一個消息。
這是HTML
<div id='messagein'></div>
<div id='message'>
<form action="" method="post" id="sendfriendd">
<div id="inpumail" >
<!-- <input type="text" name="" id="youremailaddress" size="40" value="<%= t('generales.tucorreoo') %>" class="text-input" /> -->
<input type="text" name="youremailaddress" id="youremailaddress" size="40" value="<%= t('generales.tucorreoo') %>" class="text-input" onblur="if(this.value == '') { this.style.color='#ccc'; this.value='<%= t('generales.tucorreoo') %>'}" onfocus="if (this.value == '<%= t('generales.tucorreoo') %>') {this.style.color='#000'; this.style.fontStyle='normal'; this.value=''}" style="color: rgb(120, 120, 120); font-style: normal;"/>
<label class="error" for="youremailaddress" id="youremailaddress_error">This field is required.</label>
</div>
<br>
<div id="inpumail2" >
<input type="text" name="friendsemailaddress" id="friendsemailaddress" size="40" value="<%= t('generales.amigcorreoo') %>" class="text-input" onblur="if(this.value == '') { this.style.color='#ccc'; this.value='<%= t('generales.amigcorreoo') %>'}" onfocus="if (this.value == '<%= t('generales.amigcorreoo') %>') {this.style.color='#000'; this.style.fontStyle='normal'; this.value=''}" style="color: rgb(120, 120, 120); font-style: normal;"/>
<label class="error" for="friendsemailaddress" id="friendsemailaddress_error">This field is required.</label>
</div>
<br>
<input type="submit" name="Submit" value=" <%= t('generales.enviarcorreoo') %> " class="enterrenvi">
</form>
我還是不明白到底是什麼你正在嘗試做的 – Patel