$.parseJSON()只支持标准的JSON,不标准的还是用eval("("+data+")")吧
什么 是标准的呢?
key和value都带引号的就是标准的; 而且必须是双引号,单引号也不行
understand?
举例:
string msg = ""; Model.Users currentUser; string jsonStr = ""; //JavaScriptSerializer js = new JavaScriptSerializer(); bool result = bll.UserLogin(loginID,loginPwd,out msg,out currentUser); if (!result) { jsonStr = "{"result":"false","msg":"" + msg + ""}"; context.Response.Write(jsonStr); } else { //记录登陆成功的用户到Session中 context.Session.Add("currUser",currentUser); if (string.IsNullOrEmpty(redirectUrl)) { jsonStr = "{"result":"true","msg":"OK","redirect":""}"; context.Response.Write(jsonStr); } else { jsonStr = "{"result":"true","redirect':"" + context.Server.UrlDecode(redirectUrl) + ""}"; context.Response.Write(jsonStr); } } (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|