$.get inside a setInterval after sometime open the url on the browser

100 views Asked by At

I created a chat system with polling, I use the jquery( $.getJSON) to call the url and check for new messages.

Everything works great for a while, but at least on chrome if I leave the tab open after sometime the page refresh and open the url that I use on $.get.

Anyone have ideas why this happen? The url used to get the json string never should be open directly on browser.

UPDATE: I think the problem is related with the user session, I am using Yii2 and the option "enableAutoLogin" set to true, so when the session expire if I refresh the page the session is automatically restored. I think the session is expiring and some redirect is used to automatically restore the session, this redirect then send me to the last pages url that is the url used on the $.getJSON there are any way to prevent that the server can't redirect if the call is made by ajax?

0

There are 0 answers