您的位置:首页 > Web前端 > JavaScript

javascript实现Ajax代码

2010-09-24 18:10 459 查看
function AjaxObject() {
this.req = null;
this.getRequest = function() {
if (window.ActiveXObject) {
this.req = new ActiveXObject("Microsoft.xmlhttp");
} else if (window.XMLHttpRequest) {
this.req = new XMLHttpRequest();
}
}
this.sendRequest = function(url, params, Method) {
if (!Method) {
Method = "POST";
}
this.getRequest();
this.req.onreadystatechange = this.showData;
this.req.open(Method, url, true);
this.req.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
this.req.send(params);
}
this.showData = function() {
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: