大家好,又见面了,我是全栈君。
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(“请求异常”); } } }
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/116002.html原文链接:https://javaforall.cn