Another IE issue with AJAX

Well, this code works in every browser except IE (again, as you would expect). The code should be updated based on setInterval and does this usually in all other browsers except IE, which simply does not update. Can you spot the problem?

var nick = document.getElementById("chatnick").value;
var sessid = document.getElementById("sessid").value;
var room = document.getElementById("roomid").value;
function user_read() {
  $.ajax({
 type: "GET",
 url: "methods.php",
 data: {method: "u", room: room},
 dataType: "html",
 success: function (data, status, xhr) {
     $("#userwindow").html(data);
     setTimeout(user_read, 10000);
 }
});
}
function ajax_read() {
$.ajax({
 type: "GET",
 url: "methods.php",
 data: {method: "r", room: room},
 dataType: "html",
 success: function (data, status, xhr) {
     $("#chatwindow").html(data);
     setTimeout(ajax_read, 400);
 }
});
}
function submit_msg() {
var msg = document.getElementById("chatmsg").value;
$.ajax({
    type: "GET",
    url: "methods.php",
    data: {method: "w", room: room, m: msg, n: nick, sessid: sessid},
    dataType: "html",
    success: function (data, status, xhr) {
    }
});
document.getElementById("chatmsg").value = "";
}
function keyup(arg1) { 
if (arg1 == 13) submit_msg(); 
}
setTimeout(function(){ajax_read();}, 400);
user_read();
+3
source share
2 answers

There may be a caching problem, try using POST instead of GET. In fact, use the post everywhere if you can, since IE does not cache POST requests / responses .

In addition, you clear the message sent before the completion of the ajax function, it seems suspicious. Try rewriting like this:

function submit_msg() {
var msg = $("#chatmsg").val();
$.ajax({
    type: "POST",
    url: "methods.php",
    data: {method: "w", room: room, m: msg, n: nick, sessid: sessid},
    dataType: "html",
    success: function (data, status, xhr) {
        $("#chatmsg").val("");
    }
});

}
+4
source

- , IE AJAX. - URL-, ? , .

+1

Source: https://habr.com/ru/post/1750500/


All Articles