SyntaxError:缺少;before语句使用AJAX

SyntaxError: missing ; before statement with AJAX

本文关键字:AJAX 语句 before 缺少 SyntaxError      更新时间:2023-09-26

我在执行ajax请求时遇到了这个错误,如果我根本找不到问题,我会仔细查看。这是下面的代码。

$('#post_submit').click(function() {
var poster_id = <?php echo $session_user_id; ?>;
//firebug syntax error shows the line below is the problem
var profile_user_id: <?php echo $user_id; ?>;
var post = $('#post').val();
$.post('ajax_submit_post.php', 
    {
        profile_user_id: profile_user_id,
        poster_id: poster_id,
        comment_type : comment_type,
        post: post      
    }, 
    function () {
        $('#status').append('<li class="hide">Posted</li>').hide(1000); 
    }); 
});

我想你是想用等号吗?

var profile_user_id = <?php echo $user_id; ?>;

而不是

var profile_user_id: <?php echo $user_id; ?>;