I have problem with passing string value from jQuery to C# in Web MVC.
There is my jQuery code:
$.ajax({
type: 'POST',
url: '/Account/ChangePhoneNumber',
contentType: "application/json; charset=utf-8",
data: newPhone,
dataType: 'json',
success: function (result) {
alert("We returned: " + result);
}
})
Here is my C# method:
[HttpPost]
public ActionResult ChangePhoneNumber(string data)
{
return View();
}
While debugging data parameter is always null.
What I am doing wrong?
data: {data: newPhone},