ahomeeye 发表于 2013-1-29 10:34:48

ajax设置请求头发送带中文参数

这里举个删除文件的ajax例子说明设置请求头,允许文件名带中文。

//ajax处理法var xmlHttp;function createXMLHttpRequest(){if(window.ActiveXObject){    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}else {    xmlHttp=new XMLHttpRequest();}}//操作函数function delDown(name){if(confirm("是否确定删除 "+name+" ?")){var url="/newsManager.action";var param="act=delFile&path="+name;//设置参数createXMLHttpRequest();xmlHttp.open("POST","/newsManager.action",true);          //设置请求头xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");xmlHttp.onreadystatechange=delBack;xmlHttp.send(param);//发送参数}}//回调函数function delBack(){var result;if(xmlHttp.readyState==4){   if(xmlHttp.status==200){    result=xmlHttp.responseText;      if(result=='OK'){      alert('删除成功!');    }else{      alert('删除失败!');    }   }   }}
页: [1]
查看完整版本: ajax设置请求头发送带中文参数