这个是JS文件     
   $.getJSON("regcheckuserjson.ashx", function (date) {
                        if (date.success == 1) {
                            alert('成功');
                        } else {
                            alert('失败');
                        }regcheckuserjson.ashx 文件    public void ProcessRequest (HttpContext context) {        string notice = "[{'success':'1'}]";
        context.Response.ContentType = "text/plain";
        context.Response.Write(notice);
        
    }为什么我获取这个文件得到的是 alert('失败');获取“1”这个值应该是成功啊    

解决方案 »

  1.   

    date.success == 1=》date.success == '1'
      

  2.   

    string notice = "[{'success':'1'}]";
    改:
    string notice = "{'success':'1'}";
      

  3.   

    json好像没有说开头就以 []这个中括号包裹吧。
    都是以{开头。。
      

  4.   

    JSON 数据类型格式  : [{参数:值},{参数:值}]  其中开始和结束用[]表示, 对象用{}表示  
      

  5.   


    这个应该可以的把,或者
    if (date[0].success == 1) {
      alert('成功');
      } else {
      alert('失败');
      }