I can't get data from ajax to server side. I don't know much about ajax. This is how I am using it. 'main' is the form tag
<script>
$('#main').on('submit', function (e) {
$.ajax({
url: "checkout",
type: "POST",
dataType: "json",
data: JSON.stringify(id),
success: function (mydata) {
//history.pushState('', 'checkout' + href, href);
}
});
);
</script>
[HttpPost]
public JsonResult getData(string id){
//string id will always be null
return Json(id, JsonRequestBehavior.AllowGet);
}
ajax urlischeckoutwhilepost actionresultisgetData..data: { id: 'someValue' }andurl: "@Url.Action("getData")",to generate you url correctly