R
R
RZ2018-01-24 22:40:44
AJAX
RZ, 2018-01-24 22:40:44

Is it ok to create an XMLHttpRequest instance on every ajax request?

The question before me was:
Is it okay to create an XMLHttpRequest instance on every ajax request? If yes, why? If not, then why not?
For example, a site sends a request every 5 seconds in the background to check notifications, new messages, etc... So, how to do it right? Create an instance for each request or create one?
Another example is sending a message to a chat. Would it be more correct to create one instance to check for new messages and another to send? Or does it not matter? If you create a constantly new instance, then the browser will not lie down before the arrival of the collector?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor, 2018-01-25
@sergey_zhuravlev_89

I think under each request the copy is necessary. This is how they do it everywhere. I have never seen anyone save these copies like that. If you find at least one example where people with development experience do this, it will be very interesting to look at this code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question