直接上代码
function getAjaxResult(target,postbody){
var targetUrl = target;
var postBody = postbody;
var self = this;
this.onsuccess = function(){};
this.onfailure = function(flag){};
this.getResult = function(){
var http_request;
if(window.XMLHttpRequest) {
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType("text/xml");
}
}else if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {}
}
}
http_request.onreadystatechange = function(){
if (http_request.readyState == 4) {
alert(http_request.status);
if (http_request.status == 200) {
self.onsuccess();
} else if(http_request.status == 404) {
//alert("the page is not found!");
}else {
alert("other error!");
}
}
};
http_request.open("GET", targetUrl, true);
http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
http_request.send(null); //这里 我一开始是用
http_request.send(postBody); //在IIS下面居然报405?郁闷 结果我换成null就OK了
};
}
看来IIS的机制与resin还是有不同。上次我是post到一个后缀名为.jpg的文件结果死活不行
查了一下IIS的配置这样的文件不支持GET与POST操作!
阅读(1104) | 评论(0) | 转发(0) |