使用者可以輸入一些文字,可以發送彈幕到網站上,所有線上使用者都能實時看到哦~
右上角二維碼下面的輸入框可以輸入,注意請勿輸入亂七八糟的詞語!大家一起來彈幕試試
其實類似與聊天室~
var usr = 'u' + Math.random();
$.ajax({
type: "GET",
url: "http://www.xx.xx:x/atool/" + usr,
});
$(document).ready(function() {
$('#newmessage').submit(function(e) {
var message = $("#messageinput").val();
$.ajax({
'type' : 'POST',
'url' : 'http://www.xx.xx:x/atool/put/atool/' + usr,
'data' : { 'message': message },
'dataType' : 'json',
});
// show_msg(message);
$("#messageinput").val('');
e.preventDefault();
});
var longPoll = function() {
return $.ajax({
type: "POST",
url: "http://www.xx.xx:x/atool/poll/" + usr,
async: true,
cache: false,
timeout: 100000,
success: function(data) {
console.log(data);
if (data.length > 0) {
show_msg(data.split(':')[1]);
}
return longPoll();
},
dataType: 'json'
});
};
longPoll();
});