ajax同步请求JS代码


ajax同步请求JS代码

	<script type="text/javascript">
		var txt = document.getElementById('txt');
		//1.创建XMLHttpRequest对象
		var xhr = null;
		if(window.XMLHttpRequest) {
			xhr = new XMLHttpRequest();
		}else {
			xhr = new ActiveXObject('Microsoft.XMLHTTP');
		}
		//2.打开与服务器的链接
		xhr.open('get',url,false);
		//3.发送给服务器
		xhr.send(null);
		//4.响应就绪(同步请求)
		var json = JSON.parse(xhr.responseText);
		txt.innerHTML = json;
		console.log('其他程序');
	</script>

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM