浏览 1530 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2007-09-11
代码如下:
<html>
<head>
<script>
var Request = new Object();
Request.send = function(url, method, callback, data, urlencoded) {
var req;
if(window.XMLHttpRequest){
req = new XMLHttpRequest();
}else if(window.ActiveXObject){
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.onreadystatechange = function() {
if(req.readyState == 4){
if (req.status <= 200) {
method=="POST") ? callback(req) : callback(req,data);
}else{
alert("服务器繁忙请稍后再试!");
alert(req.status);
}
}
}
if (method=="POST") {
req.open("POST", url, true);
if (urlencoded) req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
req.send(data);
} else {
req.open("GET", url, true);
req.send(null);
}
return req;
}
Request.sendRawPOST = function(url, data, callback) {
Request.send(url, "POST", callback, data, false);
}
Request.sendPOST = function(url, data, callback) {
alert(url);
Request.send(url, "POST", callback, data, true);
}
Request.sendGET = function(url, callback, args) {
return Request.send(url, "GET", callback, args);
}
//调用
Request.sendPOST("http://localhost/TestAjax?id=","", RefreshJsp);
<script>
</head>
</html>
问题的关键在“id=鼱科”这里,如果把鼱删了,或换个其他常见字,就没有问题。谁能给解释一下。RefreshJsp这个回调函数没有提供,但并不影响使。 我把该文件放到附件中,不用布署就可以执行。 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2007-09-11
连接出错了,很正常,http请求的xmlhttp异常在ie ff opera safari下面是不一样的,正好Prototype1.6正在讨论Ajax.Request.getStatus的问题,下面是ie的报错代码
IE status Error codes: 1223 : Client canceled request 12002: Server timeout 12029: Dropped connection 12030: Dropped connection 12031: Dropped connection 12152: Connection closed by server |
|
| 返回顶楼 | |
|
最后更新时间:2007-09-11
连https页面失败时,还有负一万多的返回值
|
|
| 返回顶楼 | |
|
最后更新时间:2007-09-11
问题是,我把“鼱”字删了就没事了。原因是啥呢
|
|
| 返回顶楼 | |
|
最后更新时间:2007-09-11
发送的url不应包括未encode过的字符。虽然某些服务器可以理解,但很多会有问题。例如iis。
|
|
| 返回顶楼 | |
|
最后更新时间:2007-09-14
有没有啥解决的办法呢
|
|
| 返回顶楼 | |
|
最后更新时间:2007-09-15
解决方法就是encode之。
|
|
| 返回顶楼 | |







