Home  >  Article  >  Web Front-end  >  Extjs ajax synchronous request post method parameter sending method_extjs

Extjs ajax synchronous request post method parameter sending method_extjs

WBOY
WBOYOriginal
2016-05-16 18:48:311905browse

Ajax synchronization requests generally look like this:

Copy code The code is as follows:

var conn = Ext. lib.Ajax.getConnectionObject().conn;
conn.open("POST", 'http://localhost:8080/struts2study/TreeDDGet?node=-1',false);

/ / The conn object here is actually the xmlHttpRequest object.

conn.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");
conn.send("start=" 0 "&limit= " 30 );
var rootJson = conn.responseText;

General parameters can be passed through the url followed by the background. However, you can also send parameters when you see the send parameter. I tried it on the server side. The parameters sent cannot be accepted. In Firebug, I see that the post part of the request sent is a string, which does not look like the parameters sent normally. After searching for a long time, I still couldn't find a method. Later I found an article that introduced the explanation of the send method of the xmlHttpRequest object, and then I realized that I need to set a header attribute Content-Type to tell the server to send data in form, and then the parameter string in the send method will be Interpreted by the server.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn