how to create a live chat application in php code example

Example: create a php live chat without no load

//Updates the chat
function updateChat(){
  $.ajax({

    type: "GET",
    url: "update.php",
    data: {  
        'state': state,
        'file' : file
        },
    dataType: "json",
    cache: false,
    success: function(data) {

        if (data.text != null) {
            for (var i = 0; i < data.text.length; i++) {  
            $('#chat-area').append($("<p>"+ data.text[i] +"</p>"));
        }

        document.getElementById('chat-area').scrollTop = document.getElementById('chat-area').scrollHeight;

    }  

    instanse = false;
    state = data.state;
    setTimeout('updateChat()', 1);

    },
  });
}

Tags:

Php Example