In javascript I have the following:
$.ajax({
url: "/ajax/test",
type: "POST",
dataType: "html",
data: '{"keyword" : "' + $('#tbxBrand').val() + '", "projectguid" : "<%= thisProject.ProjectGuid.ToString() %>", "userguid" : "<%= thisUser.UserGuid.ToString() %>"}',
beforeSend: function() { },
success: function(data) {
alert(data);
}
});
In the controller I have:
public ActionResult Test()
{
string keyword = Request.Form["keyword"];
return new JsonResult { Data = keyword };
}
However, the Request.Form does not contain the correct keys. In fact, the Request.Form comes out as which seems incorrect:
Request.Form = {%7b%22keyword%22+%3a+%22data%22%2c+%22projectguid%22+%3a+%22cedce659-fd91-46c8-8f69-e527a38cffc2%22%2c+%22userguid%22+%3a+%2252ff20ab-cdf1-4dae-b539-645b6bf461a7%22%7d}
I can't figure out what is wrong here. Can anyone help?
Thanks!