$.ajax({type:"GET",async:false,cache:false,url:"go.ashx",data:{name:name,tel:tel},dataType:"text",success:function(r)
                    {
                        alert(r);
                    }
                });     

解决方案 »

  1.   

    现在主要是想实现  http://myurl.com/xinxi?name=123  通过这个ulr把name后的123放到一个string中  我在网络上  得知这是 asp.net的get  post  然后 找了好多 也没有 具体实现的前台  后台代码...很晕  所以特来求一个带注释的完整demo  谢谢大家了.
      

  2.   

    string postData = "accountname=" + accountname;
                postData += ("&accountpwd=" + accountpwd);
                postData += ("&mobilecodes=" + PhoneNumber);
                postData += ("&msgcontent=" + SMSContent);
                byte[] data = encoding.GetBytes(postData);
                // Prepare web request
                System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://xxxx.aspx");            myRequest.Method = "POST";
                myRequest.Timeout = 10000;
                myRequest.ContentType = "application/x-www-form-urlencoded";
                myRequest.ContentLength = data.Length;这个就是请求了,post或者get自己设定
    对应的处理代码就根据是post或者get还获取参数了
    post就是request["xxxx"],get就是request.querystring["xxxx"]
      

  3.   

    第一种,使用aspx文件:
    前台aspx文件 JS:PageMethods.Search(deptid,tm_date_start,tm_date_end,loadResult);
    需要控件<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True" >
        </asp:ScriptManager> 
    后台aspx.cs: 
    [WebMethod]
        public static string Search(string deptid, string tm_date_start, string tm_date_end)
        {}
    需要引用using System.Web.Services;第二种,不使用服务器控件,使用jQuery.Ajax
    前台js:
    $.ajax({
            url:'ashx/DropdownBoxData.ashx?method=GetSendAndRecev&ObjectType=1&str=',
            dataType: 'json',
            async: false,
            success: function (result) {
    //处理获取的数据result
    }
    })
    用$.get()或者$.post()也可以
    后台使用的是一般处理文件ashx:public void ProcessRequest (HttpContext context)
        {
            user = (Dictionary<string, object>)context.Session["loginuser"];
            string method = context.Request["method"].ToString();
            string result = "";
            switch (method) 
            { 
                case "GetPmoveTypeDate":
                    result = GetPmoveTypeDate();
                    break;
                case "GetSendAndRecev":
                    string str = Convert.ToString(context.Request["str"]).Trim();
                    int ObjectType = Convert.ToInt16(context.Request["ObjectType"]);
                    result = GetSendAndRecev(ObjectType, str);
                    break;              
                case "GetGoodsTypeData":
                    result = GetGoodsTypeData();
                    break;
                case "GetStyleType":
                    result = GetStyleType();
                    break;
                default:
                    throw new Exception("没有请求的方法名");
                    break;
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
    }