Home > Software engineering >  [for] XMLHTTP. The send () why can't pass parameters
[for] XMLHTTP. The send () why can't pass parameters

Time:10-10

Want to learn with XMLHTTP submission form recently,
So use sohu profile modification page do exercises,
Steps are as follows;
Createobject (" msxml2 XMLHTTP ")
Then. Open "post", sohuUrl, false 'sohuUrl is I use httpfox access,
Then the setrequestheader...
Setrequestheader...
. 'beginner, don't know who can be ignored, the whole set, including cookies, referer etc.
Then send (postData) 'submitted data is name, gender, know Chinese code, full use of English, because practice

After execution, the page without any change,

. Then, I try to open "post", sohuUrl & amp; Name=DFDSF, false 'with url directly pass parameters
Results a success,


Excuse me. Is this really should be how to write???

CodePudding user response:

 
PostData="https://bbs.csdn.net/topics/name=dfdsf"
The send (postData)

CodePudding user response:

. Open the "post", sohuUrl, false
The POST must use capital here

CodePudding user response:

The
reference 1/f, allowing response:
 
PostData="https://bbs.csdn.net/topics/name=dfdsf"
The send (postData)


That's what I wrote,

CodePudding user response:

refer to the second floor xiaoyao961 response:
open "post", sohuUrl, false
The POST here have to use capital


Capital or not,

CodePudding user response:

Attach the code,
 Public Sub postDataTest () 
Dim HTTP As Object
Dim myData As String
Set the HTTP=CreateObject (" Msxml2. XMLHTTP ")

MyData="https://bbs.csdn.net/topics/introduction=fsdfs"



With HTTP
. Open the "POST", "http://i.sohu.com/profile/home/basic.htm? _sub=post ", False

'setrequestheader (Request - Line) ", "POST/profile/home/basic. HTM? HTTP/1.1 "_sub=post
. Setrequestheader "Host", "i.sohu.com"
The user-agent 'setrequestheader ", "" Mozilla/5.0 (Windows NT 5.1; The rv: 23.0) Gecko/20100101 Firefox/23.0 "
. Setrequestheader "accept", "text/HTML, application/XHTML + XML, application/XML. Q=0.9 */*; Q=0.8 "
. Setrequestheader "Accept - Language," "useful - cn, useful; Q=0.8, en - us; Q=0.5, en. Q=0.3 "
"Setrequestheader accept - encoding", "gzip, deflate
". Setrequestheader "Referer", "http://i.sohu.com/profile/home/basic.htm? The from=self "
. Setrequestheader "Cookie", "spsession=MTU4NTc3fC0xfDEzODAzMjkzNDN8d3V4aW5ndGlhbnhpYTI=- hAP7VtdzxgwNNJ + b/le2i5D6aDg=; Domain=.sohu.com; path=/; HttpOnly "
"Setrequestheader Connecion", "keep alive -
""Setrequestheader contenet -type", "application/x - www.form-urlencoded"
. Setrequestheader "Content - Length", Len (myData)

The send (myData)

'the Do While Not. ReadyState=4
'DoEvents
'Loop

'the Debug. Print. The responseText


End With

End Sub

CodePudding user response:

You have parameters in the url of the _sub=post , then myData and parameters in the the introduction=FSDFS , have never seen such usage, merge into the myData try,
Setrequestheader in Content - Length can be omitted, and you only calculate the Length of a parameter, it is wrong,

CodePudding user response:

refer to 6th floor Tiger_Zhao response:
you have a url parameter _sub=post , and then another parameters in myData the introduction=FSDFS , have never seen such usage, merge into the myData a try,
Setrequestheader in Content - Length can be omitted, and you only calculate the Length of a parameter, but wrong,


_sub=post this is I use caught tool caught the url,
I put it in the myData or not
I also deleted the Content - Length,

CodePudding user response:

The server has several parameters?
Is not your Session timeout.

CodePudding user response:

refer to the eighth floor Tiger_Zhao response:
server has several parameters?
Is not your Session timeout.


Senssion overtime should be impossible, I add parameters in the url & amp; Name=DJFKJDK, so that we can upload successfully

CodePudding user response:

The Post's head that when adding a
If not yet would you computer has a problem, I used the computer in this way, the IIS can't deal with it in the content of the Post, then the computer reshipment
 
XML. SetRequestHeader "content-type", "application/x - WWW - form - urlencoded"

CodePudding user response:

references 9 f zhangwu2cn response:
Senssion overtime should be impossible, I add parameters in the url & amp; Name=DJFKJDK, so that we can successfully uploaded

Fifth floor code name parameter, you don't have comparable,

CodePudding user response:

11 references Tiger_Zhao response:
Quote: references 9 f zhangwu2cn response:
Senssion overtime should be impossible, I add parameters in the url & amp; Name=DJFKJDK, so that we can successfully uploaded

Fifth floor code name parameter, you don't have comparable,


Use url passed & amp; The introduction=FSDFS this parameter can be
But with the send () method will fail,

CodePudding user response:

The
references to the tenth floor bakw response:
that when adding a Post head
If not yet would you computer has a problem, I used the computer in this way, the IIS can't deal with it in the content of the Post, then the computer reshipment
 
XML. SetRequestHeader "content-type", "application/x - WWW - form - urlencoded"


Anyway, the first message I set,
Is really have no idea,
Really not line, that no way out, try to reinstall the,nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • VBA
  • Related