How can I do with following questions?
1. Front-end site question is how to transfer Object-Array to JSON?
2. Back-end site question is how to get the JSON data from front-side?
Question 1:
how to make a data parameter in the AJAX?
var vItems = [];
var vItem = new Item('1', '11');
vItems.push(vItem);
vItem = new Item('2', '22');
vItems.push(vItem);
function Item(Key,Val) {
this.Key = Key;
this.Val = Val;
}
$.ajax({
type: "POST",
url: ".............",
data: ???????????????????? ,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response.d);
},
failure: function (response) {
alert(response.d);
}
});
Question 2:
How to make a correct parameter with C# function
[System.Web.Services.WebMethod]
public static string xxx(?????????)
{
return "";
}
public class VItems
{
public string Key;
public string Val;
}
PS: Please I've to use the same class between front-side and back-side like
Front-Side
function Item(Key,Val) {
this.Key = Key;
this.Val = Val;
}
Back-Side
public class VItems {
public string Key;
public string Val;
}
By the way, this issue isn't duplicative URL because it is just only one array-object, I need to handle multiple data