AJAX回发未给出预期结果 [英] AJAX Postback did not give expected result
本文介绍了AJAX回发未给出预期结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我在Ajax回发方面遇到问题.它在asp.net 4中工作正常,但在2.0上却无法运行.
这是我的代码:
Hi all,
I am having issues with ajax postback. It worked fine in asp.net 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?
推荐答案
(" ).blur(如果(
("#<%=registrationNumberTextBox.ClientID%>").blur(function() { if (
( this ).val().length > 0 ){
(this).val().length > 0) {
.ajax({ 类型:" , 网址:" , 数据:" +
.ajax({ type: "POST", url: "registration.aspx/GetAmountDue", data: "{'registrationNumber': '" +
这篇关于AJAX回发未给出预期结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文