I'm having difficulty opening message content for each unique message because I'm struggling to get the PHP variable $message['id']
to a url defined in a javascript file.
My foreach loop that echos out all of the messages for the user:
foreach($mess_data as $message){
echo'
<tr '.(($message["read"] == '0') ? 'class="unread"' : 'class=""').'>
<td class="inbox-small-cells">
<input type="checkbox" class="mail-checkbox">
</td>
<td class="inbox-small-cells">'.(($message['read'] == '0') ? '<i class="icon-envelope"></i>' : '<i class="icon-eye-open"></i>').'</td>
<td class="view-message hidden-phone">'.$message['from'].'</td>
<td class="view-message ">'.(($message['subject']) ? ''.$message['subject'].'' : 'This message has no subject.').' </td>
<td class="view-message inbox-small-cells"><!--<i class="icon-paper-clip"></i>-></td>
<td class="view-message text-right">'.$message['time'].' '.$message['date'].'</td>
</tr>';
}
}
including the JS files:
<script src="assets/plugins/jquery-1.10.1.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="assets/scripts/**inbox.js**"></script>
calling on the JS function:
jQuery(document).ready(function() {
Inbox.init();
});
A snippet from inbox.js (the line I need to get $message['id']
into from PHP is marked out by <----)
var Inbox = function () {
var content = $('.inbox-content');
var loading = $('.inbox-loading');
var loadMessage = function (name, resetMenu) {
var url = 'inbox_view.php?id=[I NEED TO GET UNIQUE ID HERE FROM PHP]; <---- the problem!
loading.show();
content.html('');
$.post(url, {}, function (res) {
if (resetMenu) {
$('.inbox-nav > li.active').removeClass('active');
}
$('.inbox-header > h1').text('View Message');
loading.hide();
content.html(res);
App.fixContentHeight();
App.initUniform();
});
}
};
}();