I have following webservice:
[webmethod]
public string MakeReservation(?? PassengersInfo)//what data type use for PassengerInfo
{
}
and in javascript I have following code.
var ResultInfo = new Array();
$("#GrdPassengerInformationMakeReservation").find('tr:not(:first)').each(function() {
var Info = new Array();
Info.push($(this).find('td:eq(1)').text());
Info.push(($(this).find('td:eq(2)')).find('select').val());
Info.push(($(this).find('td:eq(3)')).find('input').val());
Info.push(($(this).find('td:eq(4)')).find('input').val());
Info.push(($(this).find('td:eq(5)')).find('select').val());
Info.push(($(this).find('td:eq(6)')).find('input').val());
ResultInfo.push(Info);
})
$.ajax(
{ url: "Ajaxes/Reservation.asmx/MakeReservation",
contentType: "application/json; charset=utf-8",
dataType: "json",
type: "POST",
data: "{'PassengersInfo':'" + ResultInfo + "'}",
async: false,
success: function(data) {
}
});
I want to pass ResultInfo to webservice.
What data type should I use in my webservice?
Since
Infois an Array, use Array at the server side. But in that case you can pass theInfoas such instead of sending it inside another array which is again wrapper into anobjectin your ajax post method, i.e.data: Info.Or you can use ArrayList since
ResultInfocontains arrays (in this case only one array). In that case sent the ajax post withdata: ResultInfo.