Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.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 未捕获引用错误:$未定义_Javascript_Jquery - Fatal编程技术网

Javascript 未捕获引用错误:$未定义

Javascript 未捕获引用错误:$未定义,javascript,jquery,Javascript,Jquery,我一直在得到未定义的错误,我不知道如何修复它 这是我的密码: <script type="text/javascript"> function returnBlurayDisc(member_id){ var xmlhttp; if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); }else{ xmlhttp=new A

我一直在得到未定义的错误,我不知道如何修复它

这是我的密码:

<script type="text/javascript">
    function returnBlurayDisc(member_id){
         var xmlhttp;

         if (window.XMLHttpRequest){
              xmlhttp=new XMLHttpRequest();
     }else{
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }

     xmlhttp.onreadystatechange=function(){
          if (xmlhttp.readyState==4 && xmlhttp.status==200){
         document.getElementById("popup_container").innerHTML=xmlhttp.responseText;
         $("#GrayBackground").css({'height':'1900px','display':'inline'});

           }
     }

     xmlhttp.open("GET","ajax/returnAjax.php?member_id="+member_id+"&name="+name);
     xmlhttp.send();    
     }
</script>

功能返回BlurayDisc(成员id){
var-xmlhttp;
if(window.XMLHttpRequest){
xmlhttp=新的XMLHttpRequest();
}否则{
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
document.getElementById(“popup_容器”).innerHTML=xmlhttp.responseText;
$(“#GrayBackground”).css({'height':'1900px','display':'inline'});
}
}
open(“GET”、“ajax/returnAjax.php?member_id=“+member_id+”&name=“+name”);
xmlhttp.send();
}
错误为未捕获引用错误:$未定义。请帮帮我。

这行:

$("#GrayBackground").css({'height':'1900px','display':'inline'});
使用jQuery(通过
$
函数),如果您希望在页面中包含这行代码,则需要在页面中包含该库

将其放在页面顶部进行测试:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>


值得注意的是,如果您想采用jQuery——在许多情况下这是一个好主意——您可以使用它简化一系列内容,包括您现在手动执行的AJAX请求。所以,请确保文档中包含了jQuery库文件

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
如果您使用CDN,则必须在文档的
标题
部分包含类似的标签,如下所示

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>


这包括文档中的JQuery库,您最终可以使用
$
来定位元素。

您是否正确地包含了JQuery库?顺便问一下,如果您已经在使用JQuery,为什么不使用JQuery get()或ajax()函数呢?+1表示协议相对URI,以避免不安全的内容警告。