本文介绍了AJAX回发未给出预期结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好, 我在Ajax回发方面遇到问题.它在asp 4中工作正常,但在2.0上却无法运行. 这是我的代码:
Hi all, I am having issues with ajax postback. It worked fine in asp 4 but not on 2.0. This is my code:
$("#<%=registrationNumberTextBox.ClientID%>").blur(function() { if ($(this).val().length > 0) { $.ajax({ type: "POST", url: "registration.aspx/GetAmountDue", data: "{'registrationNumber': '" + $(this).val() + "'}", contentType: "application/json; charset=utf-8", dataType: "json", async: true, cache: false, success: function(msg) { $("#<%=amountDueLiteral.ClientID%>").val(msg.d); }, error: function(x, e) { alert("The call to the server side failed. " + x.responseText); } }); } else { $("#<%=amountDueLiteral.ClientID%>").html('0.00'); } });
<webmethod()>; _ Public Shared Function GetAmountDue(ByVal registrationNumber As String) As String If registrationNumber.Trim.Length > 0 Then If Student.IsValidRegistration(registrationNumber) Then Dim bi As Student.BasicInformation = Student.GetStudentByRegistrationNumber(registrationNumber) If bi.StudentId <> Nothing Then Dim result As String = String.Format("{0:n2}", bi.StudentAccount.Debit) Return result End If End If End If Return "0.00" End Function
问题是,某些东西返回了结果,但未显示在amountDueLiteral上.我该怎么办?
The problem is that, the something returned a result but not displayed on the amountDueLiteral. What do I do?
推荐答案(" #< ;%= registrationNumberTextBox.ClientID%>").blur(函数(){ 如果( ("#<%=registrationNumberTextBox.ClientID%>").blur(function() { if (
( this ).val().length > 0 ){ (this).val().length > 0) {
.ajax({ 类型:" POST" , 网址:" registration.aspx/GetAmountDue" , 数据:" {'registrationNumber':'" + .ajax({ type: "POST", url: "registration.aspx/GetAmountDue", data: "{'registrationNumber': '" +
更多推荐
AJAX回发未给出预期结果
发布评论