Ajax 异步发送邮件

很多系统中,需要实现,提交表单同时发送邮件通知相关人员的要求.特别在类似OA系统更加常见.
而一般发送邮件都会占用比提交表单+后台对数据处理的时间多很多.
想到两个思路:
1.Ajax异步发送邮件.
2.邮件信息持久化到数据库,数据库定时读取邮件信息,发送邮件

现在使用第一种方式:Ajax异步发送邮件.

<script type="text/javascript">
function send_mail(){
$.ajax({
url: "send_mail_dao.asp",
global: false,
type: "POST",
dataType: "html",
async:true,//jQuery API里面所有Demo都使用false,但是这里必须使用Default的true!
success: function(){

}
}
)
return false;
}
</script>

response.Write "<center><tr><td class='trtif1'><p>此BUG的信息已发送给:"&to_fullname
response.Write "<p>BUG已提交成功"
response.Write "<p>BUGID="&getid
response.Write "<p>请记住此Bug的ID号,这会方便你的查询和对此Bug的修复!</td></tr></table>"

response.Write "<script type='text/javascript'>"
response.Write "send_mail();"
response.Write "</script>"

// 发送Ajax请求来达到发送邮件之后,页面进行跳转[Ajax无法实现]
response.Redirect("add_bug_success.asp?toid="&getid)


对async配置项的理解:

Default: true
By default, all requests are sent asynchronous (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. [color=red]Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active[/color].
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值