dsgdfh302506 2013-08-16 03:05
浏览 176
已采纳

未捕获的ReferenceError:函数未定义jQuery,尽管定义了函数

I'm having an issue figuring out exactly why I am getting the following error, even though the function is defined.

Uncaught ReferenceError: vote_review_function is not defined

Here is my jQuery code

function vote_review_function(review_id, vote_text) {

    user_id = <?php echo $current_user->ID; ?>;

        jQuery.post("/wp-content/themes/sahifa/custom_functions/vote_reviews.php", {firstParam : review_id, secondParam : vote_text, thirdParam : user_id}, function(data) {
        //this is your response data from serv
    console.log(data);

    });
        return false;
}

and here is my HTML

<a href="javascript:void(0)" onclick="vote_review_function('<?php the_ID(); ?>', 'Yes');" class="vote_link">Yes</a>    
<a href="javascript:void(0)" onclick="vote_review_function('<?php the_ID(); ?>', 'No');" class="vote_link">No</a>

On some of the pages this works, but on most other pages I get that error above.

  • 写回答

1条回答 默认 最新

  • dongye1143 2013-08-16 03:31
    关注

    You have a syntax error in the line var anime_list_entry_id = <?php echo $anime_list_entry_id; ?>; in functions updateEpisodeSeen and jQuery(document).on('click', '.wantedStatus', function(event) { because <?php echo $anime_list_entry_id; ?> is not printing anything causing the javascript var anime_list_entry_id = ; which throws an error in the console saying Uncaught SyntaxError: Unexpected token ;

    you need to assign a default value if the said value is not present

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题