Sunny Dhiman

Sunny Dhiman

  • NA
  • 81
  • 5.9k

Call Method using Ajax.

Mar 24 2021 8:34 AM
I have make a method in under controller and i call with ajax
$(function () {
$("#btnSend").click(function () {
debugger;
//var inputName = $.trim($("#inputName").val());
var toEmail = $.trim($("#inputEmailAdress").val());
var subject = $.trim($("#inputSubject").val());
//var address = $.trim($("#inputAddress2").val());
var body = $.trim($("#comment").val());
$.ajax({
type: "POST",
url: "/Home/SendEmailAsync",
public async Task SendEmailAsync(string toEmail, string subject, string content)
{
var apiKey = "";
var client = new SendGridClient(apiKey);
var from = new EmailAddress("");
var to = new EmailAddress(toEmail);
var msg = MailHelper.CreateSingleEmail(from, to, subject, content, content);
var response = await client.SendEmailAsync(msg);
}
But i have face a issue 404

Answers (4)