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

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -