简体   繁体   中英

Uncaught SyntaxError: Unexpected token :

Uncaught SyntaxError: Unexpected token : at url: I am trying to call 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();
                }
                });


        });

});

That line is fine. I think the error is being raised because of this line:

<?php echo @userid; ?>

This code should be placed inside a PHP server script, but found its way to the browser which does not understand it. Replace that code with something appropriate (a variable or a constant string literal) and it will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM