+
95
-

如何用使用js的promise和ajax编写一个并发上传文件程序?

如何用使用js的promise和ajax编写一个并发上传文件程序?

网友回复

+
15
-

参考这篇博文,https://blog.bfw.wiki/user1/15836657831932690062.html

+
15
-
<script>
// AJAX call 1
function call_1() {
	return new Promise(function(resolve, reject) {
		let xhttp = new XMLHttpRequest();
		xhttp.onreadystatechange = function() {
			if(this.readyState == 4) {
				if(this.status == 200)
					resolve(this.responseText);
				else
					reject('Call 1 Failed');
			}
		};
		xhttp.open("GET", "ajax-1.php");
		xhttp.send();
	});
...

点击查看剩余70%

我知道答案,我要回答