Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/410.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/77.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_Error Handling_Undefined - Fatal编程技术网

Javascript jQuery ajax$未定义,但是否正确执行?

Javascript jQuery ajax$未定义,但是否正确执行?,javascript,jquery,ajax,error-handling,undefined,Javascript,Jquery,Ajax,Error Handling,Undefined,Firebug给我一个错误,说明“$未定义(70超出范围28)” 我不明白为什么,因为代码执行得很好。代码查找一个类为“like”的div,单击该类时,它会将值发送到ajax。以下是相关代码: <div class="post" id="post-<?php the_ID(); ?>"> <div id="post-<?php the_ID(); ?>-inside" class="inside"> <

Firebug给我一个错误,说明“$未定义(70超出范围28)”

我不明白为什么,因为代码执行得很好。代码查找一个类为“like”的div,单击该类时,它会将值发送到ajax。以下是相关代码:

<div class="post" id="post-<?php the_ID(); ?>">
        <div id="post-<?php the_ID(); ?>-inside" class="inside">
            <div id="like_<?php the_ID(); ?>" class="like" style="position:absolute; right: 2.5em;">
                <a id="likebtn_<?php the_ID(); ?>" class="likeimgoff" href="#"><span></span></a>
            </div>
        </div>
</div>

$(document).ready(function() {
    likestatus = 1;
    dislikestatus = 1;

    $(document).on("click", ".like", function(){
        postID = $(this).attr('id').replace('like_', ''); 

postID变量确实被赋予了正确的值,因此我不理解错误的原因。有人知道发生了什么吗?

它们可能是相互冲突的库,如Prototype等。如此处所述:

尝试将$更改为jquery,如:
jquery(document).ready(…


另外,请仔细检查您的脚本是否位于加载jquery的
行之后。

是否有示例页面,我们可以在其中看到您的问题?同意。如果问题发生在ajax调用中(示例中未出现),代码的这一部分是理解问题的关键。ajax调用是代码的一部分,我知道它不是问题的一部分(它以前工作没有问题)。几分钟后,错误消失了。但我没有对代码做任何修改来修复它。真的很奇怪。
postID = $(this).attr('id').replace('like_', '');