Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get data notifacation realtime use ajax good

$(window).load(realTime);
    function realTime() {
        $.ajax({
            type:'post',
            url:'/chat/get',
            data:{
                '_token':$('input[name=_token]').val(),
            },
            success: function (data) {
                $('#message').replaceWith(' <ul class="media-list" id="message"></ul>');
                for (var i=0; i < data.length; i++){
                    $('#message').append(' <li class="media"><div class="media-body"><div class="media"><div class="media-body">'+data[i].message+'<br/><small class="text-muted">'+data[i].from_name+'|'+ data[i].created_at+'</small><hr/></div></div></div></li>')
                }
             setTimeout(realTime, 2000);
            },
        });

    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #data #notifacation #realtime #ajax #good
ADD COMMENT
Topic
Name
6+1 =