(view has this instruction oin top:
@model MyModel
):
javascript part:
<script type="text/javascript">
$(document).ready(function() {
$("#GoButton").click(function() {
var frm = $(this).closest('form');
var params = frm.serialize();
$.ajax({
type: 'POST',
url: '@Url.ApplicationAction("MyPostAction", "myController")',
data: params,
cache: false,
success: function (data) {
alert('Completed');
},
error: function (xhr, data, message) {
//console.log(data + ": " + message);
},
dataType: "json"
});
return false;
});
});
</script>
on server side model variable will have updated with all values submitted in form and will have following parameters:
[HttpPost]
public ActionResult MyPostAction(MyModel model)
{
return Json("Ok");
}
No comments:
Post a Comment