ajax - passing array from javascript to controller MVC 4 -
i using razor , i'm having hard time passing array controller. array contains objects made , trying this:
$.ajax({ type: "post", url: "homepage/handleoperations", data: json.stringify(operationcollection), success: function (data) { alert("sucess");}, datatype: "json", contenttype: "application/json" }); and controller is:
public void handleoperations(list<string> operationcollection) { } i not required use ajax not sure how else done. in controller shows "operationcollection" contains elements null.
client side:
$.ajax({ type: "post", url: "homepage/handleoperations", data: {operations: operationcollection}, success: function (data) { alert("success"); } }); and declare class server side this:
public class operation { public int index; public string source; public string target; public int addordel; } then can have action:
public void handleoperations(operation[] operations) { }
Comments
Post a Comment