javascript - AJAX and setInterval slows down the script -


i'm working on script reads things database, instantly.

i connect using ajax , reload function interval. i'm using multible setinterval() information.

i know that slows down page , because seems impossible use on mobile devices because laggs much.

but how can that? have suggestions

thanks.

i advise against using ajax intervals.

there various methods obtaining data server. scenario suggests trying new data server. there several ways , has been discussed here on , in other places thoroughly.

the main methods server push (mainly via web-sockets) , fallback methods long polling , normal polling.

you can use asynchronous framework has fallback support older browsers.

to specific question, if insist on using polling (which repeated request of data @ interval), advised set timeout when response arrives , not use interval. way, if communication lags, won't out of sync , won't have simultaneous requests.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -