Patrick Reck
Patrick Reck

Reputation: 11374

Updating a DIV box from controller using AJAX in CodeIgniter

I am going to update a small chat between two users every minute. This is already working - however I can't figure how to do an AJAX call to update the DIV containing the actual messages.

var interval
window.onload = function(){
    interval = setInterval('updateMessages()', 2000);
};

function updateMessages() {
    $(function () {
         // UPDATE #mail_container
    });
}

What´d be a proper way approaching this?

Upvotes: 0

Views: 182

Answers (1)

routeburn
routeburn

Reputation: 1166

The easiest way is probably to include jQuery and make use of either its .append() or .html() methods.

eg. $("#mail_container").html("<p>Your chat message</p>");

See:

Upvotes: 1

Related Questions