Ajax的get post請求伺服器響應

2021-09-30 10:12:07 字數 2500 閱讀 2210

ajax的get/post方式http請求**

1.伺服器端響應ajax的同步請求,新增乙個類繼承ihttphandler介面

#region ihttphandler 成員

//獲取get請求方式提交的cardid引數

string id= context.request["cardid"];

//設定客戶端不快取,每次都請求伺服器

context.response.cachecontrol = "no-cache";

//返回的客戶端資訊

context.response.write(「測試通過!」);

//post請求方式的處理

//stream se= context.request.inputstream;

//  streamreader streamreader = new streamreader(se);

// string  str = streamreader.readtoend();

//  se.close();

//  streamreader.close();

//  context.response.write(str);

#endregion

web.config 還要配置如下

2. 伺服器端響應ajax的非同步請求,新增乙個類繼承ihttpasynchandler介面

//todo: 在此處新增建構函式邏輯

參考文獻:

Ajax的get post請求方式封裝好的js

method 請求方式,預設是get url 位址 data 要傳送的資料 function ajax catch error 判斷如果資料存在 if data if method get data 設定請求的位址 提交方式 非同步傳輸 xhr.open method,url,true if met...

getpost請求的區別

1,get是從伺服器上獲取資料,post是向伺服器傳送資料。2,get是把引數資料佇列加到提交表單的action屬性所指的url中,值和表單內各個字段一一對應,在url中可以看到。post是通過http post機制,將表單內各個字段與其內容放置在html header內一起傳送到action屬性所...

get post請求的區別

首先get和post都是網路請求方式之一。1.url可見性 get,引數url可見 post,url引數不可見 2.傳輸資料的大小 get一般傳輸資料大小不超過2k 4k post請求傳輸資料某種意義上講可以無限大 3.資料傳輸上 get,通過拼接url進行傳遞引數 post,通過body體傳輸引數...