Ajax requests do not stop loading

0

I've been experiencing this problem for many days now, I have a page where I externally loads the link from a security camera to display the image on the main page, so that's fine, the image usually shows on my page, all XHR requests do not work, they stay in the pending status all the time, it's probably because the camera link never finishes loading and then the requests wait for it to finish, how can I get around the problem? calling the video, which usually runs on the page normally:

<div id="player">
   <img src="/link-da-camera-aqui" height="420" />
</div>';

After I try to make the requests to check if there is any new message on the page, it is this request that never finishes loading:

    setInterval(function() {
        jQuery.ajax({
        url: "/verifica-novas-mensagens", success: function(resultado){
        if(resultado === '0'){
        alert('Erro na transmissão do vídeo');
        location.href="/home";
        }
        document.getElementById("novas-mensagens").innerHTML = resultado + "<br>";
        }});
    }, 8000);

The camera image works normally without crashing but its link never finishes loading and unfortunately no XHR works, thank you right away!

    
asked by anonymous 10.11.2017 / 20:10

1 answer

1

Try to do the background request to not stop the other processes, putting async: true, I do not know why you are using setInterval, if possible remove it:

jQuery.ajax({
    async : true,
    url: "/verifica-novas-mensagens", success: function(resultado){
    if(resultado === '0'){
    alert('Erro na transmissão do vídeo');
    location.href="/home";
    }
    document.getElementById("novas-mensagens").innerHTML = resultado + "<br>";
}});
    
10.11.2017 / 20:19