Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to pass three values from jquery to web method in my form.i m using the following code.But its not working..Am i using the correct syntax to pass the values?

var frm = $('#txtFromDate').val();
var to = $('#txtToDate').val();
var suppress = 'No';
$(document).ready(function() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "ProfitAndLoss.aspx/BindDatatable",
//data:JSON.stringify({ frm: $('#txtFromDate').val() },{ to: $('#txtToDate').val() },{ suppress: "No" }),
data: "{'frm': '" + frm + "','to': '" + to + "','suppress': '" + suppress + "'}",
dataType: "json",
async: true,
success: function(data) {
for (var i = 0; i < data.d.length; i++) {
$("#grdPandL").append("
" + data.d[i].UserId + "" + data.d[i].UserName + "" + data.d[i].Location + "
");
}
},
error: function(result) {
alert("Error");
alert(data.d[i]);
}
});
});
Posted

 
Share this answer
 
The line
C#
data: "{'frm': '" + frm + "','to': '" + to + "','suppress': '" + suppress + "'}",

should be
C#
data: JSON.stringify({ frm: frm, to: to, suppress:suppress }),


Refer this :http://www.aspdotnet-suresh.com/2012/07/how-to-send-or-pass-multiple-parameters.html[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900