diff --git a/static/js/check_new_messages.js b/static/js/check_new_messages.js new file mode 100644 index 0000000..a81ff24 --- /dev/null +++ b/static/js/check_new_messages.js @@ -0,0 +1,36 @@ +var user_online = true + +function check_new_messages (sender,receiver,ticket_id=null){ + // let user_online_check = document.addEventListener("mouseover"); + let data = { + 'sender':sender, + 'receiver':receiver, + 'ticket_id':ticket_id + } + + $.ajax({ + headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() }, + url: '/ru/messages/update_chat/', + type: "POST", + // async: true, + cache: false, + processData: false, + contentType: false, + // enctype: 'json', + data: JSON.stringify(data), + success: function(data){ + + if (data.msgs_count > 1){ + document.querySelector(".container-messages").innerHTML = data.html; + } else { + document.querySelector(".info_profile").innerHTML = data.html; + } + + }, + error: function (data){ + + document.querySelector(".info_profile").innerHTML = data.responseJSON.html; + + } + }); +} \ No newline at end of file diff --git a/templates/blocks/profile/b_chats.html b/templates/blocks/profile/b_chats.html index ac821e3..5308a67 100644 --- a/templates/blocks/profile/b_chats.html +++ b/templates/blocks/profile/b_chats.html @@ -38,7 +38,7 @@ {##} -