function CkLoginId() {
var Id = $("#TxtLoginId");
$.ajax({
url: "http://localhost:26850/ReportServises.asmx/GetLoginId?jsoncallback=?",
dataType: "jsonp",
data: { "loginId": Id.val() },
success: OnSuccess,
error: OnError
});
}
[WebMethod]
public void GetLoginId(string loginId)
{
string callback = HttpContext.Current.Request["jsoncallback"];
// HttpContext.Current.Response.Write(callback +"({result:'" + loginId + "'})");
string msg = JsonConvert.SerializeObject(new {Result = false, Msg = "请求失败!"});
HttpContext.Current.Response.Write(callback + msg);
HttpContext.Current.Response.End();
}
后台方法注释的是可以的,为什么序列化的就不行了。求大家解惑。。
msg是json字符串,明显和注释的不一样了,少了()
==>
HttpContext.Current.Response.Write(callback +"("+ msg+")");