答:var xhr = new XMLHttpRequest(); xhr.open("GET", "http://example.com/ajax.php"); xhr.onreadystatechange = function(){ if (xhr.readyState == 4 && xhr.status == 200) { var response = xhr.responseText; // Do something with response } } xhr.send();
js使用XMLHttpRequest 封装一个http请求,并返回调用结果,直接给出代码
最新推荐文章于 2023-07-12 19:22:59 发布