我有一个像“http://172.26.76.83/service/service.php?str”这样的网址。当我运行这个网址时,我收到“欢迎光临”。如何在 AJAX 中编写代码以获得“欢迎光临”
最佳答案
你应该多搜索一下。在此Link您有简单的 GET 方法,如下所示:
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("demo").innerHTML = xhttp.responseText;
}
};
xhttp.open("GET", "http://172.26.76.83/service/service.php?str", true);
xhttp.send();
}
关于javascript - 如何从ajax代码中获取响应文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38201310/