[英]Ajax In QueryMethod Calling in Classic Asp For Email sending
I am Having Problem in getting AJAX Method in JQUERY To Post on my Classic ASP Page Method to send email. 我在JQUERY中获取AJAX方法以在我的经典ASP页面方法上发布以发送电子邮件时遇到问题。 Here is my Code Please Tell me what mistake i'm doing.
这是我的代码,请告诉我我在做什么错误。 Also Suggest me how to Redirect to previous html page after the execution of my ap page function.
还建议我在执行ap页面功能后如何重定向到上一个html页面。
function QuickEmail() {
$.ajax({
type: "POST",
url: "emailsending.asp",
data: '{FirstName: "' + $("#txtFirstName").val() + '",LastName:"' +
$("#txtLastName").val() + '",Email:"'
+ $("#txtEmail").val() + '",ContactNo:"' + $("#txtContactNo").val() + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
$.unblockUI();
}
function OnSuccess(response) {
$.msgBox({ title: "Message Sent!", content: "Message has been sent successfully.", type: "info" });
}
Here is my ASP Page 这是我的ASP页面
enter code here
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<%
dim FirstName
dim LastName
dim EmailAdd
dim Contact
FirstName = Request("txtFirstName")
LastName = Request("txtLastName")
EmailAdd = Request("txtEmail")
Contact = Request("txtContactNo")
Set Mail = CreateObject("CDO.Message")
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="smtp.gmail.com"
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="xxxxxx@gmail.com" 'You can also use you email address that's setup through google apps.
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xxxxxxxx"
Mail.Configuration.Fields.Update
Mail.Subject= FirstName
Mail.From= "xxxxxx@gmail.com"
Mail.To=EmailAdd
Mail.TextBody=FirstName & vbCrLf & LastName & vbCrLf & Contact & vbCrLf & EmailAdd
Mail.Send
Set Mail = Nothing
Response.Redirect("index.html")
%>
</body>
</html>
You pass your data in this way: 您可以通过以下方式传递数据:
data: '{FirstName: "' + $("#txtFirstName").val()
+ '",LastName:"' + $("#txtLastName").val()
+ '",Email:"' + $("#txtEmail").val()
+ '",ContactNo:"' + $("#txtContactNo").val() + '"}',
when you now access you data with the form-identities, you will recieve possibly malformed or null
data. 现在,当您使用表单标识访问数据时,您将收到格式错误或为
null
数据。
Instead try either: 而是尝试以下任一方法:
send your form instead of manually parsed JSON-Data: that would look like this 发送您的表单,而不是手动解析的JSON-Data:
data: document.forms.quickmail.data, 数据:document.forms.quickmail.data,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.