在ajax中怎么用XMLHttpRequest,post,get发送接收数据
/*在有中文参数时,接收方需要使用UTF-8方式对数据进行解码
*不支持post附件
*/
functiongetXmlHttpRequest(){
varxmlHttpRequest=null;
try{
xmlHttpRequest=newActiveXObject("Msxml2。XMLHTTP");
}
catch(e1){
try{
xmlHttpRequest=newActiveXObject("Microsoft。XMLHTTP");
}catch(e2){
xmlHttpRequest=null;
}
}
if(xmlHttpRequest==null&&typeofXMLHttpRequest!='undefined')
{
xmlHttpRequest=newXMLHttpRequest();
}
returnxmlHttpRequest;
}
/*使用post方式发送数据
*url:submit路径
*arguments:参数,如name=jese&sex=womanz,中文数据时使用'name='+getEncodeURIComponent('李四')+'&sex='+getEncodeURIComponent('男')进行编码
点击查看更多 [ajax] [post] [get] [XMLHttpReque]
(本文来源) https://www.netded.com/a/jishuyingyong/2009/1114/5144.html
版权声明:
作者:[db:作者]
链接:https://www.shoujiroot.com/archives/23476.html
来源:手机教程
文章版权归作者所有,未经允许请勿转载。
共有 0 条评论