I have this strange situation where I have a WebMethod in WebService which needs to return a generic list and also need to have output Parameter attached to it.
And $.ajax({ }) need to call this webservice and get both return value and outparameter in .success().
Web Service is as below:
[WebMethod]
public static List < Category > GetAllCategory(out int TotalCountRecord)
{
List < Category > AllValues = new List < Category > ();
//Some ADO.NET Code to Call Stored Procedure with output Value;
SqlParameter OutParameter = new SqlParameter("@RecordCount", SqlDbType.Int);
OutParameter.Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
TotalCountRecord = (int)(OutParameter.Value);
//Pls. Don't Mind these sequence of the code.
return AllValues;
}
Now is there a Possible way for me to call these code for JQuery Ajax Like
var a = 0;
$.ajax({
url: 'WebService1.asmx/GetAllCategory',
method: 'post',
dataType: 'json',
data: JSON.stringify({TotalCountRecord: a}),
contentType: 'application/json; charset=utf-8',
success: function(data) {
//Add data to Table
//Show RecordCount at Footer of the Table
}
Is these a way to address this situation?