方式一:
get()传参:
$.get("CookieDemo.ashx?cmd=login", {
ID: "LEE",Pwd:"PAN"},
function (data, status) {
alert(data);
});
post()传参:
$.post("CookieDemo.ashx?cmd=login", {
ID: "LEE", Pwd: "PAN"},
function (data, status) {
alert(data);
});
在“CookieDemo.ashx”文件中处理并返回:
public void ProcessRequest(HttpContext context)
{
string strReturn="";
context.Response.ContentType = "text/plain";
string cmd = context.Request.QueryString["cmd"].ToString();
switch (cmd)
{
case "login":
strReturn = "SUCCESS!";
break;
}
context.Response.Write(strReturn);
}
方式二:
get()传参:
$.get("CookieDemoS.aspx?cmd=login", { id: "lipan" }, function (data) {
alert(data);
});
post()传参:
$.post("CookieDemoS.aspx?cmd=login", { id: "lipan" }, function (data) {
alert(data);
});
在“CookieDemo.aspx”文件中处理并返回:
protected void Page_Load(object sender, EventArgs e)
{
string my = Request.QueryString["cmd"];
Response.ContentType = "text/plain";
Response.Clear();
Response.Write("这个是我的新信息");
Response.End();
}
方式三:
get传值:
<a href="CookieDemoS.aspx?page=1">CookieDemoSPage</a>
protected void Page_Load(object sender, EventArgs e)
{
string data= Request.QueryString["page"];
}
post:用于提交要处理的数据,例如验证登录信息。
get:用于从从指定的资源请求数据。