ajax流程与fetch

原生 ajax

	var xhr;
	if (window.XMLHttpRequest){
	    //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
	    xhr = new XMLHttpRequest();
	} else {
	    // IE6, IE5 浏览器执行代码
	    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhr.open('GET', url);
	xhr.responseType = 'json';
	
	xhr.onload = function() {
	  console.log(xhr.response);
	};
	
	xhr.onerror = function() {
	  console.log("Oops, error");
	};
	
	xhr.send();

jq ajax

https://segmentfault.com/a/1190000012836882

猜你喜欢

转载自blog.csdn.net/zdhanunity/article/details/94591539
今日推荐