$.ajax({
type: "post",
url: "LogoHandler.ashx",
data: { User: username.value, PassWord: userpass.value },
success: function (msg) {
alert(msg)
}
});
后台LogoHandler.ashx
Imports System.Web
Imports System.Web.Services
Public Class LogoHandler
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim User As String = Convert.ToString(context.Request.Params("User"))
Dim IsOk As String = "1"
context.Response.ContentType = "text/plain"
context.Response.Write(IsOk)
End Sub
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
后台能取到值,在返回前台时,取不到值。alert(msg)没有执行到这句还是输出为空?
没执行到说明动态页出问题了。
$.ajax({
type: "post",
url: "LogoHandler.ashx",
data: { User: username.value, PassWord: userpass.value },
success: function (msg) {
alert(msg)
},
error: function (xhr) { alert(xhr.responseText)}
}); error: 看看有没有错误信息。$.ajax({
type: "post",
url: "LogoHandler.ashx",
data: { User: username.value, PassWord: userpass.value },
success: function (msg) {
alert(0);
// alert(msg)
}
});
你直接弹出一个常量试试,如果弹出了0,说明就是你没有显示写出自己的返回值类型。
加一个:dataType:'text' 你怎么知道执行到success,肯定就么有执行success了,所以才没有alert(msg)..
加了error回调没有,是否执行了error