<WebMethod()> Public Shared Function micro() As String
Dim context As HttpContext = HttpContext.Current
Dim ClientID As String = context.Session(const_SESSION_CLIENT_ID)
Dim UserID As String = context.Session(const_SESSION_USER_ID)
If (ClientID Is Nothing OrElse UserID Is Nothing) Then Return SerializeErrorMessage("User not logged in")
Dim serializer As JavaScriptSerializer = New JavaScriptSerializer()
serializer.MaxJsonLength = Integer.MaxValue
Dim s As String = U.Settings(ClientID, UserID)
'Return serializer.Serialize(s).ToString()
Return s.ToString()
End Function
s 返回我想要的字符串,但是当我从客户端获取并发出警报时,我得到 [object Object]
客户端:
datsaa = {};
$.ajax({
type: "POST",
url: "v.aspx/micro",
data: datsaa,
contentType: "application/json; charset=utf-8",
dataType: "text json",
beforeSend: function (xhr)
{
xhr.setRequestHeader("Content-type",
"application/json; charset=utf-8");
},
success: function (b)
{
alert(b);
},
error: function (XMLHttpRequest, textStatus, errorThrown)
{
}
});