asp.net mvc 5 - Best way to send complex data object to controller via ajax? -
i want send complex object view (via ajax) controller. know can like:
json.stringify(mycomplexobject);
and retrieve values in controller. best way it? i'm thinking sort of info contract between view , controller better?
you can utilize following
@using(html.beginform("youraction","yourcontroller",formmethod.post)) { .... } <script> $(function () { $('form').submit(function () { if ($(this).valid()) { $.ajax({ url: this.action, type: this.method, data: $(this).serialize(), success: function (result) { alert('ok'); } }); } homecoming false; }); }); </script>
and in controller
public actionresult youraction(yourmodel model) { }
hope help you
ajax asp.net-mvc-5
No comments:
Post a Comment