简体   繁体   中英

Best way to implement status check using javascript

I've got to implement a scenario where I have to listen to a certain request status from server side. What is the best way to implement this feature without using an ajax request every pre defined time period.

What I think of implementing is an ajax request to the web resource every 5 seconds to poll the status of the server until the status becomes true. If then, I will end the polling sequence and shift into a different screen. Is this the optimum way of doing such a thing. or else...

What is the most feasible way to implement such a feature.

I think push notifications would work better in a case like this.

Last time I used SignalR . If you like low level stuff better, you can simply use websokets , but is easier to use a framework what relies on it.

Based on your comment:

I'm more of thinking of a solution which I can implement from the front end side! would help that way cus I have limited access to the backend!

the possible techniques are getting very small, and doing a possibly minimal AJAX check request every x seconds sounds reasonable. I cannot come up with other simple front-end only solution.

That of course doesn't mean there isn't a better solution out there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM