Ajax方法總結
1 $.ajax方法
$.ajax({
type:"GET",
data:{id:json[i].ID},
url:"../../Ajax/ShowLamp.aspx",
async:false,
success:function(data){
$("#PointsContent").html(data)
}
})
2 $.get方法
$(document).ready(function(){
$('#send1').click(function(){
$.get("get1.aspx",{
username:$('#username').val(),
content:$('#content').val()
},function(data,textstatus)
{
$('#comment').html(data);
});
});
3.ajax頁麵獲取參數的方法
我們知道,get和post提交方式,獲取request的方式是不同的。
第1種,接收用get 方法傳輸的數據的寫法:
protected void Page_Load(object sender, EventArgs e)
{
string id = Request.QueryString["name"];
string website = Request.QueryString["website"];
Response.Write(id + "< br>" + website);
Response.Write("你使用的是" + Request.RequestType + "方式傳送數
據");
}
第2種,接收用post 方法傳輸的數據的寫法:
protected void Page_Load(object sender, EventArgs e)
{
string id2 = Request.Form["name2"];
string website2 = Request.Form["website2"];
Response.Write(id2 + "< br>" + website2);
Response.Write("你使用的是" + Request.RequestType + "方式傳送數據");
}
string id4 = Request["name4"];
string website4 = Request["website4"];
Response.Write(id4 + "< br>" + website4);
第3種,同時接受get和post 方法傳送數據的代碼寫法:
A 寫法
string id3 = Request.Params["name3"];
string website3 = Request.Params["website3"];
Response.Write(id3 + "< br>" + website3);
B 寫法
string id4 = Request["name4"];
string website4 = Request["website4"];
Response.Write(id4 + "< br>" + website4);
$.ajax({
type:"GET/POST"
data:{id:"11"},
url:"../../Ajax/ShowLamp.aspx",
async:false,
success:function(data){.......}
})
所以一定要分清楚ajax提交的方式!
4 ajax傳中文參數方法
"GetDate.ashx?location=" + encodeURI("漢字")
最後更新:2017-04-03 05:40:39
上一篇:
C#委托基礎5——泛型委托Action
下一篇:
Android開發8——利用pull解析器讀寫XML文件
數字化革命來襲,公司應該如何應對?
2011年7月編程語言排行榜,Objective-C將成為年度語言
阿裏雲發布研發協同雲 推動百萬企業開發運維一體化
將PPT轉化為PDF我的JAVA代碼實現!
Android開發22——廣播接收者BroadcastReceiver的原理和注冊方式
struts.xml中提示content of element type "package" must match
如何閱讀別人的代碼
雲服務器和虛擬主機有什麼區別
Netty隨記之ChannelHandlerContext與Channel的writeAndFlush的區別
Ubuntu 13.04 的 10 個最佳新特性