POST請求的兩種方式

2022-06-01 09:09:07 字數 1003 閱讀 3732

1

在viewcontroller中的**如下

23 - (void

)viewdidload

1213

#pragma mark -send post 2-

14/**15

使用nsdata(二進位制資料)承載請求資訊,多用於上傳檔案

16*/

17 -(void)sendpost2:(nsstring*)urlstr

6162

#pragma mark -send post 1-

63/**64

get相似,使用url承載請求資訊,多用於登陸註冊,填表等操作(這種方式的post請求也能用get請求實現,但是get請求,傳送的資料是裸露的)

65*/

66 -(void)sendpost1:(nsstring*)urlstr

8990

9192

#pragma mark -**方法-

9394 - (void)connection:(nsurlconnection *)connection didreceiveresponse:(nsurlresponse *)response

102 _data.length = 0

;103

}104

105 - (void)connection:(nsurlconnection *)connection didreceivedata:(nsdata *)data

111112 -(void)connectiondidfinishloading:(nsurlconnection *)connection

116117 -(void)connection:(nsurlconnection *)connection didfailwitherror:(nserror *)error

120121

122123 - (void

)didreceivememorywarning

view code

C 後台post請求常用的兩種方式

首先建立乙個httpwebrequest,並且宣告請求方法和請求頭 程式使用http協議和伺服器互動主要是進行資料的提交,通常資料的提交是通過 get 和 post 兩種方式來完成,然後,我們需要進行拼接引數,這種請求方式,提交的資料按照 key1 val1 key2 val2 的方式進行編碼,ke...

Js的兩種post方式

第一種提交post的方式是傳統方式,判斷瀏覽器進行post請求。var xmlobj 定義xmlhttprequest物件 如果當前瀏覽器支援xmlhttp request,則建立xmlhttprequest物件 function submitarticle act,cityname,antique...

Ajax中的get和post兩種請求方式的用法

ajax中我們經常用到get和post請求.那麼什麼時候用get請求,什麼時候用post方式請求呢?在做回答前我們首先要了解get和post的區別.1 get是把引數資料佇列加到提交表單的action屬性所指的url中,值和表單內各個字段一一對應,在url中可以看到。post是通過http post...