JS中http函数无响应



我在JS函数中编码请求HTTP,但它不起作用(控制台无消息,无响应,无数据)。虽然,不是我第一次请求HTTP,但我没有在我的代码中找到错误。你能开导我吗?下面是我的代码:

function dmd_art(){
var httpRequest = getHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4){
document.getElementById('annimation_loader').style.display = 'none';
document.getElementById('aff_pub').innerHTML = httpRequest.responseText;
}  
}
httpRequest.open('GET', 'includes/article.php', true)
}

getHttpRequest()是使XMLHttpRequest适用于所有web浏览器的函数

function dmd_art(){
var httpRequest = getHttpRequest();
httpRequest.onreadystatechange = function () {
if (httpRequest.readyState === 4){
document.getElementById('annimation_loader').style.display = 'none';
document.getElementById('aff_pub').innerHTML = httpRequest.responseText;
}  
}
httpRequest.open('GET', 'includes/article.php', true)
httpRequest.send(/* If there're some data send here */); // Add this
}

是啊,少了点什么,对吧?如果你不发送请求,那什么也做不了。

最新更新