Sending a JSON array to be received as a Dictionary

后端 未结 2 521
别那么骄傲
别那么骄傲 2020-12-17 02:04

I have a method with the following signature:

public ActionResult RenderFamilyTree(string name, Dictionary children)

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 02:53

    There is a syntax error in the javascript object literal. The two key/value pairs in the array should be assigned to a named property alongside "name" (ex: "myProperty").

    $('#div_render').load(
    "<%= Url.Action("RenderFamilyTree") %>", 
    { 
         name: 'Raul',
         myProperty: [
             {key:'key1',value:'value1'},
             {key:'key2',value:'value2'}
         ] 
    }, 
    function() {                
        alert('Loaded');
    }
    

    );

提交回复
热议问题