0
返回數據我有這個jQuery的功能,我從一個DOM事件致電:jQuery函數Ajax不是從的WebMethod
function GetAdhesiveWeight(volatiles1, volatiles2, testedWeight) {
var volatiles1 = $('#<% = FormView1.FindControl("textVolatiles1").ClientID %>').val()
var volatiles2 = $('#<% = FormView1.FindControl("textVolatiles2").ClientID %>').val()
var testedWeight = $('#<% = FormView1.FindControl("textTestedWt").ClientID %>').val()
$.ajax({
type: "POST",
url: "NomexLine500A.aspx/CalcAdhesiveWeight",
data: '{"dblVolatiles1":"' + volatiles1 + '", "dblVolatiles2":"' + volatiles2 + '", "dbTestedWeight":"' + testedWeight + '"}',
dataType: "json",
success: function (data) {
$('#<%=FormView1.FindControl("textPerVolatiles").ClientID %>').val(data.d)
}
});
}
它會從這個事件叫做:
$('#<% = FormView1.FindControl("textVolatiles2").ClientID %>').bind('change', function() {
GetAdhesiveWeight();
});
事件觸發罰款並進入GetAdhesiveWeight函數。 在隱藏文件我的代碼的Web方法會從AJAX調用:
<WebMethod()>
Public Shared Function CalcAdhesiveWeight(ByVal dblVolatiles1 As Double, ByVal dblVolatiles2 As Double, ByVal dblTestedWeight As Double) As String
Dim dblVolatiles As Double
dblVolatiles = (((dblVolatiles1 - dblVolatiles2) * 2) * 1000)
Return Format(dblTestedWeight - dblVolatiles, "#.00")
End Function
我不是使它成爲VB的功能,當我設置斷點。我認爲ajax中有些東西是錯誤的。
我試圖用FireBug進行調試,但是我對這個工具還不太滿意。我對jQuery相當陌生,所以任何反饋都會很棒。
你在網絡控制檯中看到什麼錯誤? – PSL
請檢查下面的鏈接 [如何對格式的JSON換ASP淨的WebMethod,這通吃類參數] [1] [1]:HTTP:/ /stackoverflow.com/questions/21023259/how-to-format-json-for-asp-net-webmethod-that-takes-class-parameter/21026621#21026621 –