encodeURIComponent(arg1)=encodeURIComponent(value1)&encodeURIComponent(arg2)=encodeURIComponent(value2)&…。。

 

注: encodeURIComponent 返回一个包含了 charstring 内容的新的 String 对象(Unicode 格式), 所有空格、标点、重音符号以及其他非 ASCII 字符都用 %xx 编码代替,其中 xx 等于表示该字符的十六进制数。 例如,空格返回的是 “%20” 。 字符的值大于 255 的用 %uxxxx 格式存储。参见 JavaScript 的 encodeURIComponent() 方法。

 

在了解了上面的内容后我们现在用ajax的XMLHttpRequest对象向服务器分别用GET和POST方式发送一些数据。

 

GET 方式

var postContent =”name=” + encodeURIComponent(“xiaocheng”) + “&email=” + encodeURIComponent(“xiaochengf_21@yahoo。com。cn”);

xmlhttp。open(“GET”, “somepage” + “?” + postContent, true);

xmlhttp。send(null);

 

POST 方式

 

var postContent =”name=” + encodeURIComponent(“xiaocheng”) + “&email=” + encodeURIComponent(“xiaochengf_21@yahoo。com。cn”);

xmlhttp。open(“POST”, “somepage”, true);

xmlhttp。setRequestHeader(“Content-Type”, “application/x-www-form-urlencoded”);

//xmlhttp。setRequestHeader(“Content-Type”, “text/xml”); //如果发送的是一个xml文件

xmlhttp。send(postContent);


上一篇:s2-045代码执行漏洞分析s2-045
下一篇:textarea换行符如何实现换行

90后自助游的旅游行为研究问卷表

中学数学教学中的模型思想调查问卷表

FENDI品牌消费的问卷调查表

AHP法调查问卷表

LEC法调查问卷表

观众参加虚拟展会的决策影响因素调查问卷

维吾尔族学前儿童汉语学...

湖南长沙市生育津贴政策...

浅谈岗位廉洁教育的方法与途径【3858字】

旅游英语推进邢台市旅游...

摩羯座运势2022,摩羯座...

浅议体态律动在小学音乐课堂教学中的运用

羟肟类萃取剂对嗜酸氧化...

信息技术茬旅游专业教學...

基于中频信号的家用治疗...

试析多元智能理论茬体育...

PF--1415反击式破碎机箱体设计开题报告