我试图使用Mootool的Ajax从VB.NET获取值。 但我继续获取Default.aspx的整个HTML代码,而不是我在Ajax中调用的函数的返回值。
这是我在Default.aspx中的脚本(使用Mootools 1.5)
var year = $('<%=ddlYear.ClientID%>').value;
var month = $('<%=ddlMonth.ClientID%>').value;
var week = $('<%=ddlWeek.ClientID%>').value;
var updateChart2 = new Request ({
method: "post",
url: "/Default.aspx/updateChart",
data: {"year":year, "month":month, "week":week},
update: "divChart",
onFailure: function () {
alert('error');
},
onSuccess: function (response) {
console.log(response);
//some code
}
});
updateChart2.send();
这是我在Default.aspx.vb中的代码
<WebMethod()> _
Public Shared Function updateChart(ByVal year As String, ByVal month As String, ByVal week As String) As String
Dim a As String = ""
'some code to change "a" value
Return a
End Function
我的代码中有什么问题吗?