ajax基础
发布时间:2020-12-15 21:50:42 所属栏目:百科 来源:网络整理
导读:var http; function xuanti(obj){ var url=null;//写action路径 sendRequest(url); } //创建XML请求 function createXMLHttpRequest(){ if(window.XMLHttpRequest){ http=new XMLHttpRequest(); }else if(window.ActiveXObect){ try { http= new ActiveXObjec
var http;
function xuanti(obj){ var url=null;//写action路径 sendRequest(url); } //创建XML请求 function createXMLHttpRequest(){ if(window.XMLHttpRequest){ http=new XMLHttpRequest(); }else if(window.ActiveXObect){ try { http= new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } } //发送请求 function sendRequest(url){ createXMLHttpRequest(); http.open("post",url,true); http.onreadystatechange=process; http.send(); } //回调函数,处理action返回的结果 function process(){ if(http.readyState==4){ if(http.status==200){ var result=http.responseText; }else{ window.alert("请求异常"); } } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |