$(document).ready(function (){ let users = $('.users'); let send= $('#btn-send'); let message= $('#new_message'); let form =$('#form'); let chat_pic= $('.chat_history_user_pic'); let chat_name= $('.chat_history_user_info'); let chat_id =$('.chat_history_user_id'); let user_id= $('.user_id'); let chat_history= $('.chat_history_chat'); message.keyup(function(){ if(message.val()!= ''){ send.prop("disabled", false); //send.css("background-color", "blue"); } else { send.prop("disabled", true); //send.css("background-color", 'gray'); } }); let loadMessages= function(user1_id, user2_id){ chat_history.empty(); $.ajax({ url:'php/get_messages.php', method: 'POST', dataType:'json', data: { user1: user1_id, user2: user2_id }, dataType: 'json', success: function(result){ if(result != ''){ for(let i=0; i'; chat_history.append(item); } else { let item='

'+result[i].chat_message+'

'; chat_history.append(item); } } } else{ let item='

Nincsennek még üzenetek.

'; chat_history.append(item); } }, error: function(result){ console.log(result); } }) } let sendMessage= function(user1_id, user2_id){ $.ajax({ url:'php/new_message.php', data: { new_message: message.val(), user_id: user1_id, user_2: user2_id, }, dataType: 'text', method:'POST', success: function(result){ let parsed= jQuery.parseJSON(result); $(".chat_history_none").remove(); let item='

'+parsed.message+'

'; chat_history.append(item); }, error: function(result){ console.log(result); } }); message.val(''); } let getUsers= function(){ $.ajax({url:'php/get_users.php', method:'POST', dataType: 'json', data: { id: user_id.html() }, success: function(data){ for(let i=0; i'+data[i].id+''; users.append(item); } let single_user= $('.users_user'); for(let i=0; i