Search code examples
javascriptajaxxmlhttprequest

How to make data stable until we get back response in xhr?


When i send a simple XMLHttpRequest()

With my asnyc = 1

The HTML page I've loaded just blinks, why?

Can't it be stable until response is got?

I am using responseText to fetch contents.

My actual code is running at: http://fastchat.ga/chat

And also,

Sometimes the request is not sent, why?

Can anyone has an answer?


Solution

  • Fist of all,

    setInterval(showMsg,5000);
    

    Please dont use strings for calling functions... That way is better.

    Then, I don´t notice the blinking, but if the field is a boolean, you should use a boolean instead of using 1 (it's not a falsy value, but it's not a true). What I'd recommend, is to avoid using the argument, given that it's default value is true.

    Good luck