国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > AJAX > 正文

學習Ajax教程,詳細了解Get與Post

2024-09-01 08:26:03
字體:
來源:轉載
供稿:網(wǎng)友

學習ajax教程,詳細了解get與post

get方式:
作用:可傳送簡單數(shù)據(jù)
大小:url最大長度是2083 bytes,可以用于get傳遞數(shù)據(jù)的長度是2048 bytes
包含體:數(shù)據(jù)追加到url中發(fā)送,也就是http的header傳送

post方式:
作用:可傳送簡單復雜數(shù)據(jù)
大小:web.config里限制
包含體:數(shù)據(jù)在http請求的實體內(nèi)容里傳送

ajax用post模式傳送數(shù)據(jù).需注意:
1.設置header的context-type為application/x-www-form-urlencode確保服務器知道實體中有參數(shù)變量.通常使用xmlhttprequest對象的setrequestheader("context-type","application/x-www-form-urlencoded;")
2.參數(shù)是名/值一一對應的鍵值對,每對值用&號隔開.如 name=abc&sex=man&age=18.
3.參數(shù)在send(參數(shù))方法中發(fā)送
4.服務器端請求參數(shù)區(qū)分get與post.例如asp.net中以request.form["name"]對實體中的參數(shù)請求.這時url參數(shù)請求request.querystring["name"]將引發(fā)異常

<javascript language="javascript>
function stateevent()
{
if(xmlhttpobject.readystate == 4)
{
if(xmlhttpobject.status == 200)
{
//code
}
}
}

function createxmlhttp()
{
if(window.activexobject)
{
return new activexobject("microsoft.xmlhttp");
}
else if (window.xmlhttprequest)
{
return new xmlhttprequest();
}
}

function start()
{
var paramstring = "name=abc&sex=man&age=18";
var xmlhttpobject = createxmlhttp();
xmlhttpobject.onreadystatechange = stateevent;
xmlhttpobject.open("post","test.aspx",true);
xmlhttpobject.setrequestheader("content-type","application/x-www-form-urlencoded;"); //設置服務器響應請求體參數(shù)
xmlhttpobject.send(paramstring);
}
</script>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 扎兰屯市| 新闻| 鱼台县| 安顺市| 天镇县| 饶河县| 金阳县| 哈密市| 德兴市| 田阳县| 蓝田县| 城市| 溧水县| 寿宁县| 江都市| 松溪县| 浪卡子县| 平乡县| 白朗县| 鄂托克前旗| 宜川县| 大荔县| 蓝田县| 安丘市| 邳州市| 铁岭县| 宝山区| 休宁县| 鸡东县| 德钦县| 遂宁市| 驻马店市| 湘阴县| 嵊泗县| 沁源县| 鄂托克前旗| 资中县| 莒南县| 新化县| 镇江市| 永昌县|