未捕获的SyntaxError:意外的令牌:

时间:2014-07-15 21:14:01

标签: jquery codeigniter

Uncaught SyntaxError:意外的令牌:在url:   我正在尝试调用controller insert / getdata

<script>
$(window).load(function(){
    // do something 
$(document).ready(function () {

                //d=   <?php echo $userid; ?>
                $.ajax({   
                    url:"http://localhost/CodeIgniter/index.php/insert/getdata", //The url where the server req would we 
                    async: false,
                    type: "POST", //The type which you want to use: GET/POST
                   data: {activeNodeID : <?php echo $userid; ?>}, //The variables which are going.

                    //This is the function which will be called if ajax call is successful.
                    success: function(response){

                    $("#ques").html(response);
                    $("#ques").show();
                }
                });


        });

});

1 个答案:

答案 0 :(得分:2)

这条线很好。我认为由于这一行而引发错误:

<?php echo @userid; ?>

此代码应该放在PHP服务器脚本中,但是找不到它的浏览器。用适当的东西(变量或常量字符串文字)替换该代码,它将起作用