Guest User

Guest User

  • Tech Writer
  • 18
  • 2.9k

Send Data By Ajax.

Mar 25 2021 6:04 AM
I have send data by ajax but i have face null value in controller
Ajax Code
$(function () {
$("#btnSend").click(function () {
//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());
debugger;
var employee = {};
employee.toEmail = $('#inputEmailAdress').val();
employee.inputName = $('#inputName').val();
employee.subject = $('#inputSubject').val();
employee.body = $('#comment').val();
$.ajax({
type: "POST",
url: '/Genric/SendEmail',
//data: "{ toEmail: '" + toEmail + "', subject: '" + subject + "', body: '" + body + "', inputName:'" + inputName + "'}",
data: '{emp: ' + JSON.stringify(employee) + '}',
 
 
This C# code
public string SendEmail(string toEmail, string subject, string content)--here toEmail null 
{
var apiKey = "";
var client = new SendGridClient(apiKey);
 

Answers (1)