First of all, I suggest using POST, not GET. create a javascript array. insert the data inside it. send it to the action web api method using JSON.Stringify .. and then process further logic.
In the web api, create a model variable .. and create a list object.
Below is the code.
Javascript
var demoarray=[]; demoarray.push({"test1":"hi", "test2":"hello"}); //test1 and test2 are model variable names in web api and hi and hello are their values
you can repeat the process in a for loop or something to add multiple values.
$.ajax({ url:"http://localhost..", type: "POST", data: JSON.Stringify(demoarray), contentType: "application/json", success: function(data) { }, error: function(data) { } });
WEB API Code Create a Model Class and Two Properties
public string test1 {get; set;} public string test2 {get; set;}
controller code
[Httppost] public void actionmethod(List<modelclass> obj) { int i=0; for(i=0; i<obj.count; i++) {
source share