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

EtherNetservers年付仅10美元,美国洛杉矶VPS/1核512M内存10GB硬盘1Gpbs端口月流量500GB/2个IP

EtherNetservers是一家成立于2013年的英国主机商,提供基于OpenVZ和KVM架构的VPS,数据中心包括美国洛杉矶、新泽西和杰克逊维尔,商家支持使用PayPal、支付宝等付款方式,提供 60 天退款保证,这在IDC行业来说很少见,也可见商家对自家产品很有信心。有需要便宜VPS、多IP VPS的朋友可以关注一下。优惠码SUMMER-VPS-15 (终身 15% 的折扣)SUMMER-...

特网云(1050元),IP数5 个可用 IP (/29) ,美国高防御服务器 无视攻击

特网云特网云为您提供高速、稳定、安全、弹性的云计算服务计算、存储、监控、安全,完善的云产品满足您的一切所需,深耕云计算领域10余年;我们拥有前沿的核心技术,始终致力于为政府机构、企业组织和个人开发者提供稳定、安全、可靠、高性价比的云计算产品与服务。官方网站:https://www.56dr.com/ 10年老品牌 值得信赖 有需要的请联系======================特网云美国高防御...

香港云服务器 1核 1G 29元/月 快云科技

快云科技: 12.12特惠推出全场VPS 7折购 续费同价 年付仅不到五折公司介绍:快云科技是成立于2020年的新进主机商,持有IDC/ICP等证件资质齐全主营产品有:香港弹性云服务器,美国vps和日本vps,香港物理机,国内高防物理机以及美国日本高防物理机产品特色:全配置均20M带宽,架构采用KVM虚拟化技术,全盘SSD硬盘,RAID10阵列, 国内回程三网CN2 GIA,平均延迟50ms以下。...

ajax实例为你推荐
range3S压力开关上RANGE和 DIFF是什么意思?xhtmlHTML4,HTML5,XHTML 之间有什么区别fast路由器FAST无线路由器要怎么设置a8处理器什么是A8处理器?支付宝账单查询支付宝账单怎么查antiarp电脑一开机就出现发现新硬件xAntiArp Miniport,提示安装,很是影响开机速度,怎么办?里程碑2里程碑2怎么样360官网打不开360浏览器打不开网页360官网打不开360打不开!详单查询手机短信详单怎么查询
天津服务器租赁 免费com域名申请 cn域名个人注册 wordpress主机 lnmp yardvps 香港机房 全能主机 我爱水煮鱼 免费mysql 卡巴斯基官方免费版 已备案删除域名 双十一秒杀 91vps 网络空间租赁 免费智能解析 drupal安装 数据库空间 测速电信 空间服务器 更多