Reputation: 87
i have jquery datatable i need to pass 2 arguments with this code does not works perhaps does not call the procedure
var params = {
"name": "ProgressivoRichiesta", "value": $("input[name='<%=txtTargaResponsabile.UniqueID%>']").val(),
"name": "sDataIncidente", "value": $("input[name='<%=txtDataSinistro.UniqueID%>']").val()
}
$('#listReceivedMail').DataTable({
destroy: true,
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": "CinfoService.svc/ProcedureName",
"data": params,
thanks
Upvotes: 0
Views: 916
Reputation: 4918
To pass the parameters the way you're currently doing it requires this change:
var model = { ProgressivoRichiesta: $("input[name='<%=txtTargaResponsabile.UniqueID%>']").val(),
sDataIncidente: $("input[name='<%=txtDataSinistro.UniqueID%>']").val()
};
$('#listReceivedMail').DataTable({
destroy: true,
"dataType": 'json',
"contentType": "application/json; charset=utf-8",
"type": "GET",
"url": "CinfoService.svc/ProcedureName",
"data": JSON.stringify(model),
But to pass them using the API, you need to do this:
$('#listReceivedMail').DataTable({
"ajax": {
"url": "CinfoService.svc/ProcedureName",
"data": function ( d ) {
return $.extend( {}, d, {
ProgressivoRichiesta: $("input[name='<%=txtTargaResponsabile.UniqueID%>']").val(),
sDataIncidente: $("input[name='<%=txtDataSinistro.UniqueID%>']").val()
});
}
},
Upvotes: 1