I am wanting to pass a dictionary of type to my controller via an Ajax post.
The main reason here is the post may have between 1-3 key value pai
Something like (javascript)
dict = new Object();
dict['12'] = 5;
dict['13'] = 6;
dict['1000'] = 21;
dict['9'] = 13;
dict['13'] = 48;
$.post('/client.mvc/mypostaction/', { myDictionary: dict });
You can then post the dict object to your controller using a Dictionary as property type.
ActionResult MyPostAction(Dictionary myDictionary)
edit from author's code second time:
The following works for me, when having a Dictionary. isn't going to work after all.
Make your post like:
var dict = new Object();
dict['13'] = 9;
dict['14'] = 10;
dict['2'] = 5;
$.post('controller.mvc/Test', { 'kvPairs': dict }, function(obj) { $('#output').html(obj.Count); });