jq ashx获取不得到值

<script language="javascript" type="text/javascript">
          $(document).ready(function(){
              $("#Button1").click(function(){
          
              $.ajax({
                   type:"post",
                   dataType:"text",
                   url:"Handler.ashx",
                   data:"username"+$("#Text1").val(),
                   success:function(msg){
                   alert(msg);
               }
              })
              })
          })
         
    </script>

ashx:

 public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string name = string.Empty;
        if (context.Request["username"] != null)
        {
             name = context.Request["username"].ToString();
        }
        context.Response.Write(name);
    }

  在这里我怎么获取不到username的值呢?

翻阅古今
浏览 444回答 4
4回答

拉风的咖菲猫

data:"username"+$("#Text1").val()=>data:{"username:"+$("#Text1").val()}

慕容3067478

data:"username"+$("#Text1").val()   写错了   改为:data:"username="+$("#Text1").val(),
打开App,查看更多内容
随时随地看视频慕课网APP