1. Create the Web Service To Send Email and Call that Web Service Using JQuery.
<script type="text/javascript">
function CallServiceMail() {
var name = $('#nameMsg').val();
var email = $('#emailMsg').val();
var phone = $('#phoneMsg').val();
var messageemail = $('#messageMsg').val();
var messageto = "info@abakinfotech.com";
var subjectemail = "Enquiry from web site contact form";
$.ajax({
type: "POST",
url: "SendEmail.asmx/SendMail",
data: "{'nameemail': '" + name + "', 'emailid': '" + email + "', 'phone': '" + phone + "', 'message': '" + messageemail + "', 'emailTo': ' " + messageto + "', 'subjectemail': ' " + subjectemail + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError
});
function OnSuccess(data, status) {
if (data.d == "1") {
$('#nameMsg').attr("value", "");
$('#emailMsg').attr("value", "");
$('#phoneMsg').attr("value", "");
$('#messageMsg').attr("value", "");
$("#contactsubmit").show();
window.location = "thankyou.html#successMsg"
}
}
function OnError(request, status, error) {
if (request.statusText == 0) {
$("#contactsubmit").show();
alert("There is some error in sending mail, sorry for incovinience");
}
}
}
</script>
No comments:
Post a Comment