ajax实例AJAX异步传输用到哪些对象?具体实例。

ajax实例  时间:2022-03-02  阅读:()

AJAX异步传输用到哪些对象?具体实例。

function ajax(){ this.method; this.url; this.responsetype; this.content; var http_request = false; this.getExecObj = function(reValue){ 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("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { //window.alert("创建XMLHttpRequest对象实例失败."); return false; } if(this.method.toLowerCase()=="get") { http_request.open(this.method, this.url, true); } else if(this.method.toLowerCase()=="post") { http_request.open(this.method, this.url, true); http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); } else { //window.alert("http请求类别参数错误。"); return false; } http_request.send(this.content); var reTextResponse = function() { if (http_request.readyState == 4) { if (http_request.status == 200) { reValue(http_request.responseText); } else { //alert("页面有异常。"); } } } var reXMLResponse = function() { if (http_request.readyState == 4) { if (http_request.status == 200) { reValue(http_request.responseXML); } else { //alert("页面有异常。"); } } } if(this.responsetype.toLowerCase()=="text") { http_request.onreadystatechange = reTextResponse; } else if(this.responsetype.toLowerCase()=="xml") { http_request.onreadystatechange = reXMLResponse; } else { //window.alert("参数错误。"); return false; } } } // 调用方法 var _ajax = new ajax() _ajax.method = "post"; //是get还是post _ajax.url = "Returnlist.aspx"; //请求的地址 _ajax.responsetype = "text"; //处理返回内容的类型 _ajax.content = "id=2"; //发送的内容 _ajax.getExecObj( //对返回值处理 function(str){ document.getElementById("select1").outerHTML = "<select name='select1' onchange='rsp(this)'><option value='0'>选择大产品</option>"+ str + "</select>" } ); 刚好有个项目代码 给你看看

HostDare($33.79/年)CKVM和QKVM套餐 可选CN2 GIA线路

关于HostDare服务商在之前的文章中有介绍过几次,算是比较老牌的服务商,但是商家背景财力不是特别雄厚,算是比较小众的个人服务商。目前主流提供CKVM和QKVM套餐。前者是电信CN2 GIA,不过库存储备也不是很足,这不九月份发布新的补货库存活动,有提供九折优惠CN2 GIA,以及六五折优惠QKVM普通线路方案。这次活动截止到9月30日,不清楚商家这次库存补货多少。比如 QKVM基础的五个方案都...

野草云提供适合入门建站香港云服务器 年付138元起 3M带宽 2GB内存

野草云服务商在前面的文章中也有多次提到,算是一个国内的小众服务商。促销活动也不是很多,比较专注个人云服务用户业务,之前和站长聊到不少网友选择他们家是用来做网站的。这不看到商家有提供香港云服务器的优惠促销,可选CN2、BGP线路、支持Linux与windows系统,支持故障自动迁移,使用NVMe优化的Ceph集群存储,比较适合建站用户选择使用,最低年付138元 。野草云(原野草主机),公司成立于20...

香港 1核 1G 5M 22元/月 美国 1核 512M 15M 19.36元/月 轻云互联

轻云互联成立于2018年的国人商家,广州轻云互联网络科技有限公司旗下品牌,主要从事VPS、虚拟主机等云计算产品业务,适合建站、新手上车的值得选择,香港三网直连(电信CN2GIA联通移动CN2直连);美国圣何塞(回程三网CN2GIA)线路,所有产品均采用KVM虚拟技术架构,高效售后保障,稳定多年,高性能可用,网络优质,为您的业务保驾护航。官方网站:点击进入广州轻云网络科技有限公司活动规则:用户购买任...

ajax实例为你推荐
网络受限制或无连接为什么电脑连wifi显示受限制或无连接庞大庞大的庞字是什么意思资源优化配置资源优化配置的前提条件小项目现在有什么好的小项目可以做啊4g上网卡什么是4G无线上网卡官方网店官方网店和官方旗舰店有什么区别?怎样上传照片如何上传照片网游木马网游盗号木马是怎么工作的?安全网络攻防大赛安全知识竞赛详单查询请问在中国移动网站如何查询详单
分销主机 Hello图床 777te 云全民 php空间推荐 中国电信测速网 免费测手机号 国外免费asp空间 监控服务器 卡巴斯基官网下载 阿里云邮箱个人版 windowssever2008 alexa世界排名 godaddy退款 建站论坛 hosting ubuntu安装教程 在线tracert 饭桶 let 更多