1
WebServiceにWebMethod
があり、ジェネリックリストを返す必要があり、パラメータが出力されている必要があります。JQuery AjaxがWebメソッドに戻り値と出力値の両方を要求しています
$.ajax({ })
は、このWebサービスを呼び出して戻り値と出力パラメータの両方を.success()
に取得する必要があります。
Webサービスは以下の通りです:
[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;
}
今jQueryのAjaxのよう
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
}
のためにこれらのコードを呼び出すために私のために可能な方法は、この状況に対処する方法があり、これらはありますか?
..私は私の終わりにいくつかの愚かなミスを犯したが、あなたの提案が働いた!!!!どうもありがとうございます..... –