Start by defining a model that will represent the data that you work with so that you work with strong types and get rid of objectugliness by the method AddClient:
public class Benef
{
public string Nome { get; set; }
public string DataNasc { get; set; }
public string GrauParent { get; set; }
}
then your web method will take an array of this model:
[WebMethod]
public static string AddClient(Benef[] benefs)
{
return "some result";
}
and on the client you must define an array of parameters:
var parameters = {
benefs: [
{
Nome: $('#txtBenefNome').val(),
DataNasc: $('#txtBenefDataNasc').val(),
GrauParent: $('#txtBenefGrauParent').val()
}
]
};
$.ajax({
type: 'POST',
url: 'Client.aspx/AddClient',
data: JSON.stringify(parameters),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function(result) {
alert(result.d);
}
});
JSON.stringify, , . , json2.js script .