0

While passing dictionary values from ajax to MVC controller I couldn't get the "value" from the dictionary but "key" value is available. This is what I have tried.

    function makeCall() {
        var data = {};
        data['one'] = [];
        data['one'].push("1");
        data['one'].push("2");
        data['two'] = [];
        data['two'].push("1");
        data['two'].push("2");

        var name = "panelData";
        $.ajax({
            url: '@Url.Action("AjaxSample", "Home")',
            data: { complexObject: data},
            //contentType: "application/json; charset=utf-8", //sending type
            //dataType: "json", //expected type
            success: successFunc,
            error: errorFunc
        });
    }

enter image description here

If I pass Dictionary<int,int> or Dictionary<string,int> it's working.

Kumaran Raj K
  • 365
  • 1
  • 11
  • https://stackoverflow.com/questions/4710729/post-json-dictionary – Amir Jelo Dec 12 '19 at 08:02
  • Does this answer your question? [POST json dictionary](https://stackoverflow.com/questions/4710729/post-json-dictionary) – Nikki9696 Dec 12 '19 at 14:37
  • @Nikki9696 The issue occur only when the value type of dictionary is IEnumerable. If we try to pass the value to be some other class type other than IEnumerable it works. – Kumaran Raj K Dec 13 '19 at 04:48

0 Answers0