PHP:
<?php
$user_info = getInformation(); // gets user's information and puts it into an array, $user_info[0] is their ID, $user_info[1] is their username, $user_info[2] is their display name
?>
JQuery:
$(document).ready(function() {
$(document).on("click", ".btn", function(event) {
event.preventDefault();
var post = $(this);
$.ajax({
url: 'assets/script.php',
type: 'POST',
data: { user_id: <?php echo $user_info[0] ?>, display_name: <?php echo $user_info[2] ?> },
success: function(data) {
alert(data);
}
});
});
});
However, when I click on the button (.btn), it shows the following error in the console:
ReferenceError: Test is not defined
Test being the display name of the user that's getting this error.
What's wrong?