What should be the DataType of Controller's Action method for JSon type posting
I want to know that what should be the datatype
of Controller Action Paramter's for JSon post value?
I'm posting the form using jQuery.Post method...
E.g.
jQuery.post('/Customer/PostData', jQuery(document.forms[0]).serialize(), function (data) {
alert('Successfully post..!');
});
I want to add another parameter with post data.. let's say I also want to post CustomerID
along with form data JSON
..
Could you please let me know what should I keep my controller paramter's datatype? I tried with List<string,string>
as a controller's paramter data type , but it is开发者_开发问答 not working.
Thanks in advance..
You could add a hidden field to your form containing the value you would like to send:
<%= Html.Hidden("CustomerID") %>
and then:
$('#CustomerID').val('123');
var dataToPost = $(document.forms[0]).serialize();
$.post('/Customer/PostData', dataToPost, function (data) {
alert('Successfully post..!');
});
精彩评论