我已经实现了一个Web方法来获取单个记录..Web方法正常工作但是。数据没有在jQuery AJAX中显示
jQuery& Ajax代码
function GetBillDetail() {
debugger;
var ClientId = jQuery('#<%=HiddenFieldCompanyId.ClientID%>').val()
$.ajax({
type: "POST",
url: "<%=mstr_WebsitePath%>webservice/ClientSearch.asmx/GetBillDetaill",
data: '{ClientId: "' + ClientId + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {// Data Not Getting Here
debugger;
var billReport = r.d;
jQuery('#ClientName').html(billReport.ClientName);
jQuery('#CityName').html(billReport.City);
jQuery('#ClientAddress').html(billReport.Address);
jQuery('#ClientPhoneNo').html(billReport.PhoneNo);
},
failure: function (r) {
alert(r.d);
}
});
}
网络方法:
<WebMethod()> _
Public Function GetBillDetaill(ByVal ClientId As String) As List(Of BillReport)
Dim billReportList As New List(Of BillReport)
Dim mrow_Bill As DataRow
With BillingDetailBOL.getBillCorrectionDetailBOL(ClientId)
For Each mrow_Bill In .Rows
Dim billReport As New BillReport()
billReport.ClientName = mrow_Bill("ClientName").ToString()
billReport.City = mrow_Bill("LocalityName").ToString()
billReport.Address = mrow_Bill("Address").ToString()
billReport.PhoneNo = mrow_Bill("Phone").ToString()
billReportList.Add(billReport)
Next
End With
Return billReportList
End Function
通过网络方法调用BOL方法
Public Shared Function getBillCorrectionDetailBOL(ByVal ClientId As String) As DataTable
Try
_ILog.WriteToLog("", Severity.Information, "BillingDetailBOL.vb", "getBillCorrectionDetailBOL", "Get Client bill Detail", Level.INFO)
Dim mobj_dset As New DataSet
Return BillingDetailDAL.GetBillCorrectionDetailDAL(ClientId).Tables(0)
Catch piEx As PIException
_ILog.LogException("", Severity.ProcessingError, "BillingDetailBOL.vb", "getBillCorrectionDetailBOL", piEx)
Throw piEx
Catch ex As Exception
_ILog.LogException("", Severity.ProcessingError, "BillingDetailBOL.vb", "getBillCorrectionDetailBOL", ex)
Throw ex
End Try
End Function
通过BOL调用DAL方法
Public Shared Function GetBillCorrectionDetailDAL(ByVal mstr_ClientId As String) As DataSet
Try
_ILog.WriteToLog("", Severity.Information, "BillingDetailDAL.vb", "GetBillCorrectionDetailDAL", "Get Client Detail", Level.INFO)
Dim commandparameters() As SqlParameter = New SqlParameter(0) {}
commandparameters(0) = New SqlParameter("@ClientId", mstr_ClientId)
Return SqlHelper.ExecuteDataset(Utilities.WebConfiguration.SQLConnectionString, CommandType.StoredProcedure, "GC_GetCompanyDetail", commandparameters)
Catch piEx As PIException
_ILog.LogException("", Severity.ProcessingError, "BillingDetailDAL.vb", "GetBillCorrectionDetailDAL", piEx)
Throw piEx
Catch ex As Exception
_ILog.LogException("", Severity.ProcessingError, "BillingDetailDAL.vb", "GetBillCorrectionDetailDAL", ex)
Throw ex
End Try
End Function
我无法在success: function (r)
获取数据任何人都知道如何解决此问题。
答案 0 :(得分:0)
对于VB.Net,你
WebMethod
应该是static
Shared
Public Shared Function GetBillDetaill(ByVal ClientId As String) As List(Of BillReport)
答案 1 :(得分:0)
尝试以json格式字符串返回数据。
序列化将数据列表到json并将函数的返回类型更改为字符串。