hunte_zzk
hunte_zzk
  • 发布:2015-10-15 16:24
  • 更新:2015-10-16 04:42
  • 阅读:1184

ajax遇到pasererror问题

分类:MUI
mui.ajax('http://*****/Handler/CommonHandler.ashx',{  
            data:{  
                action:'login',  
                userName:loginInfo.account,  
                userPsw:loginInfo.password  
            },  
            dataType:'json',  
            type:'post',  
            timeout:10000,  
            success:function(data){  
                alert(11111);  
            },  
            error:function(xhr,type,errorThrown){  
                alert(xhr.responseText);  
                alert(type);  
            }  
        })

后台输出的
context.Response.Write(string.Format("{{result:'{0}',msg:'{1}'}}", result, msg));
运行完后执行了error里的两个弹出,一个是弹出{result:'true',result:'登录成功!'}//这个应该是表示执行成功了吧,但是为什么是在error里面执行的。
另一个弹出的则是pasererror

2015-10-15 16:24 负责人:无 分享
已邀请:
果汁

果汁

可能原因:
1、服务器脚本里定义输出类型为json;
2、输出的json格式不规范。

用jquery的ajax试试是不是一样的效果。

现在什么都讲究标准啦,我们老老实实按标准来吧。我下面列举几个符合标准的例子:
{"myvalue":1}
{"myvalue":"red"}
{"myvalue":["black",250]}

该问题目前已经被锁定, 无法添加新回复