When the link below is clicked
<a class="end" href="#">End</a>
The below code runs which deletes a user from a table and shows a hidden div. The user that is deleted is the first user from an array. Once the first user is deleted, the second user gets an email.
$("a.end").click(function() {
//Delete user from DB
$.post(
base_url + "index.php/home/end_wait",
{
chat_id: chat_id,
end_user: end_user,
end_email: end_email
},
function(data) {
},
"json"
);
// Open alert div
$('.new_wait').show('slow', function() {
$('div.new_wait').show();
});
return false;
});
The hidden div:
<div class="new_wait" style="display:none;">Hello second user</div>
How can I make the div appear only for the second user? The div is placed in the header, so the second user should be able to see it regardless of what page he/she is viewing. Something like stackoverflow does when you earn a badge.
CodeIgniter and PHP are not push technologies. You are only able to construct a response to a browser who makes a request. If the second user does not interact with the web server with $.post(), you cannot push data to them in this manner.
Either look up Web Sockets, Comet Programming, or Polling.