javascript取后台值,以及xmlhttp:open方法中的POST、GET参数的区别
function createXMLHttpRequest() { var xmlHttp; try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(ex) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(except) { xmlHttp = false; } } if (!xmlHttp && typeof XMLHttpRequest != 'undefined') { xmlHttp = new XMLHttpRequest(); } return xmlHttp; } function FormValidator(theForm) { var emp_no = theForm.empNo.value; var pwd = theForm.pwd.value; var xmlHttp = createXMLHttpRequest(); xmlHttp.open("get", "<%=basePath%>empCheck.action?empCd=" + emp_no + "&empPwd=" + pwd, false); xmlHttp.send(null); var message = xmlHttp.responseText; message = message.replace(/[\r\n]/g, ''); if(message == "noExistFlag") { alert("gege"); return (false); } else if(message == "retireFlag") { alert("aaa"); return (false); } else if(message == "invalidFlag") { alert("bbbb"); return (false); } return (true); }
将响应信息作为字符串返回
语法
strValue = oXMLHttpRequest.responseText;
Example
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
xmlhttp.open("GET", "http://localhost/books.xml", false);
xmlhttp.send();
alert(xmlhttp.responseText);
备注
变量,此属性只读,将响应信息作为字符串返回。
XMLHTTP尝试将响应信息解码为Unicode字符串,XMLHTTP默认将响应数据的编码定为UTF-8,如果服务器返回的数据带BOM(byte-order mark),XMLHTTP可以解码任何UCS-2 (big or little endian)或者UCS-4 数据。注意,如果服务器返回的是xml文档,此属性并不处理xml文档中的编码声明。你需要使用responseXML来处理。
[解决办法]
是分享吧 ,接分
[解决办法]
楼主其实可以写一篇博客了都。。
那样子还能存储下来~
[解决办法]