$.ajax({type:"GET",async:false,cache:false,url:"go.ashx",data:{name:name,tel:tel},dataType:"text",success:function(r)
{
alert(r);
}
});
{
alert(r);
}
});
解决方案 »
- 用mysql做数据库,用多个WCF来访问多个mysql数据库,是否支持MSDTC下的分布式事务?
- JS如何禁用LinkButton?
- 【window2000server下IIS发布.NET网站出错】哭求解决方法!
- 如何根据节点内容写Xquery语句
- 为什么DataGrid 的HeaderTemplate中TextBox.Text完法取出
- 请教一个Datagrid分页的问题,具体代码附后。
- DataGrid AllowSorting
- 一个关于“索引超出了数组界限”的问题,急!急!急!
- GridView控制表头折行的问题!!!
- DropDownList问题?
- Session在网页之间的数据传递
- checkboxlist在客户端显示的checkbox状态改变不能传递到服务器端
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"]
前台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);
}