ajax表单提交验证,浏览器兼容问题

2016-12-09 19:27:52来源:CSDN作者:zqd_java人点击

获取浏览器:
function createXmlHttp() {		var xmlHttp;		try { // Firefox, Opera 8.0+, Safari			xmlHttp = new XMLHttpRequest();		} catch (e) {			try {// Internet Explorer				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");			} catch (e) {				try {					xmlHttp = new ActiveXObject(							"Microsoft.XMLHTTP");				} catch (e) {				}			}		}		return xmlHttp;	} 
表单提交验证:
 var xhr = createXmlHttp();            // 2.设置监听xhr.onreadystatechange = function() {if (xhr.readyState == 4) {if(xhr.status==200){var data=xhr.responseText;var success="success";var json=$.trim(data);if(success==json){document.getElementById("myform").submit();}else{alert("单位名称重复,请重新输入");return false;} }}}// 3.打开连接xhr.open("POST","TbDweckRepeat?time="+ new Date().getTime()+"&dwmc="+dwmc+"&UpdId="+id, false);// 4.发送xhr.send(null); 



最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台