如何制作“;发送“;当我的邮件被发送时使用单词,并将其替换为“”;邮件发送“;当页面停止加载或发送邮件时


How to make "sending" word when my mail is being sent and replace it with "Mail sent" when page stop loading or mail is sent

我使用php mailer发送邮件,我希望浏览器在发送邮件或浏览器发送邮件时显示类似"Sending"的内容,并在发送邮件后显示"Message send"。我如何实现这一点?哪种语言使用javascript或php或其他语言。提前谢谢。

使用ajax可以做到这一点。我使用jquery:

http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

在$.ajax之前和$(".button").click(function() {之后,您可以添加消息并阻止按钮和表单在提交表单时重新提交。

这个教程有点旧,但你可以从中学习。我更喜欢使用$('#formId').submit(function(e) { e.preventDefault();而不是$(".button").click(function() {,有了提交,你不仅可以跟踪点击按钮,还可以在键盘上点击enter时跟踪提交。