It was necessary to obtain data from the data-user_id attribute
$('.submit_button').click(function () { $.ajax( { url:'/../title/comment', type:'post', data: { 'comment_text': $('#comment_area').val(), 'title_id' : $(this).data('title_id'), }, success:function (data) { if (data != "u're guest") if (data !='update') $('#comment_area').prepend(data); else { alert($('.submit_button').data('user_id')); ) } else alert('Чтобы оставлять комментарии войдите в профиль'); //Checking if user is logged in } } ) });
Displays undefined, while the values from the title_id attribute can be obtained
