Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript和jQuery隐藏方法在通过ajax函数加载数据时不起作用_Javascript_Jquery_Ajax - Fatal编程技术网

javascript和jQuery隐藏方法在通过ajax函数加载数据时不起作用

javascript和jQuery隐藏方法在通过ajax函数加载数据时不起作用,javascript,jquery,ajax,Javascript,Jquery,Ajax,这是我的ajax代码 var ajaxRequest; if (window.XMLHttpRequest) { ajaxRequest = new XMLHttpRequest(); } else { ajaxRequest = new ActiveXObect('Microsoft.XMLHTTP'); } ajaxRequest.onreadystatechange = function() { if ( ajaxRequest.read

这是我的ajax代码

var ajaxRequest;

if (window.XMLHttpRequest) {
    ajaxRequest = new XMLHttpRequest();
} else {
    ajaxRequest = new ActiveXObect('Microsoft.XMLHTTP');
}

ajaxRequest.onreadystatechange = function() {
                if ( ajaxRequest.readyState==4 && ajaxRequest.status==200 ) { 
                    alert('data loaded');
                    var loadedData = document.getElementById('page-data');
                    loadedData.innerHTML=ajaxRequest.responseText; 
                }
            }

// load data from server
function getData() {
    ajaxRequest.open('POST', 'loadData.php', true);
    ajaxRequest.send();
}
alert()
函数未工作,但
getElementById()
函数工作正常
有人能告诉我为什么
alert()
函数不起作用吗?如果我写另一条语句来代替
alert()
函数,它也不起作用,但下一行起作用了

我打赌你按下可选复选框上的按钮——“不显示来自此站点的警报”并关闭警报。如果我错了,在你的代码中搜索-
函数alert(){}
jQuery与此有什么关联?您的代码或问题中没有jQuery,但它被标记并位于问题标题中。请不要包含不相关的信息。包含jQuery意味着我已经尝试了js和jQuery。