0

Im trying to bebug some javascript in firefox and I keep getting this error.
SyntaxError: syntax error

data: {action: addtocart, id: <br />

the javascript is this:

<script type="text/javascript">
    jQuery(document).ready(function($){
        $('#button').on('click', function(e){

            $.ajax({
                url: 'shopping2/includes/functions.php',
                type: 'POST',
                 data: {action: addtocart, id: <?php echo $pid; ?> },
                cache: false,
                success: function(data){
                    alert(data);
                }
            });
        });
    });
</script>

where is the error?

2
Contributors
1
Reply
11
Views
2 Years
Discussion Span
Last Post by hericles
0

Chrome tells me it is the < on line ten, where you are tring to insert some php.
that line
data: {action: addtocart, id: <?php echo $pid; ?> },

If your PHP was being compiled correctly this wouldn't be visible to the browser so I'm gueesing that isn't the problem.
But from the error you gave, it still the < that is causing the problem. What should $pid be?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.