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>" } ); 刚好有个项目代码 给你看看

Hostodo独立日提供四款特价年付VPS套餐 最低年付$13.99

前天,还有在"Hostodo商家提供两款大流量美国VPS主机 可选拉斯维加斯和迈阿密"文章中提到有提供两款流量较大的套餐,这里今天看到有发布四款庆祝独立日的七月份的活动,最低年付VPS主机13.99美元,如果有需要年付便宜VPS主机的可以选择商家。目前,Hostodo机房可选拉斯维加斯和迈阿密两个数据中心,且都是基于KVM虚拟+NVMe整列,年付送DirectAdmin授权,需要发工单申请。(如何...

远程登录VNC无法连接出现

今天有网友提到自己在Linux服务器中安装VNC桌面的时候安装都没有问题,但是在登录远程的时候居然有出现灰色界面,有三行代码提示"Accept clipboard from viewers,Send clipboard to viewers,Send primary selection to viewers"。即便我们重新登录也不行,这个到底如何解决呢?这里找几个可以解决的可能办法,我们多多尝试。...

iON Cloud七月促销适合稳定不折腾的用户,云服务器新购半年付8.5折,洛杉矶/圣何塞CN2 GT线路,可选Windows系统

iON Cloud怎么样?iON Cloud今天发布了7月份优惠,使用优惠码:VC4VF8RHFL,新购指定型号VPS半年付或以上可享八五折!iON的云服务器包括美国洛杉矶、美国圣何塞(包含了优化线路、CN2 GIA线路)、新加坡(CN2 GIA线路、PCCW线路、移动CMI线路)这几个机房或者线路可供选择,有Linux和Windows系统之分,整体来说针对中国的优化是非常明显的,机器稳定可靠,比...

ajax实例为你推荐
a8处理器苹果A7,A8,A9处理器有什么区别?什么是cookie有时遇到网页提示禁止第三方cookie是什么意思?小项目适合在家做的小项目有什么?网络限速软件有什么比较好的网络限速的软件soap是什么意思rbq是什么意思?sg什么意思篮球中内线和外线是什么意思暂停线程Java里如何暂停一个线程,达到一定条件后又唤醒线程?淘宝推广网站谁有好的淘宝推广网站介绍下哦!或推广技巧!里程碑2里程碑2怎么样分销渠道案例王老吉分销渠道案例分析
猫咪永久域名收藏地址 如何申请域名 免费域名注册网站 德国vps 过期域名抢注 naning9韩国官网 directspace omnis 镇江联通宽带 圣诞促销 200g硬盘 网站卫士 免费活动 厦门电信 西安主机 广州虚拟主机 lamp的音标 杭州电信宽带优惠 成都主机托管 万网注册 更多