I have a recursive call that checks the readystate of an object and I confess that I haven't worked with <object>'s in the past.
I'm curious to know if this recursion is a necessary evil and if there is a way to speed it up or is this considered good practice? Currently it's taking roughly 15 seconds to return a successful readystate.
Contributor
2853 Points
1372 Posts
mImageViewer.readyState != 4 loop is 15 seconds slow
Feb 06, 2017 08:19 PM|adamturner34|LINK
Hi Folks,
I have a recursive call that checks the readystate of an object and I confess that I haven't worked with <object>'s in the past.
I'm curious to know if this recursion is a necessary evil and if there is a way to speed it up or is this considered good practice? Currently it's taking roughly 15 seconds to return a successful readystate.
All-Star
57864 Points
15488 Posts
Re: mImageViewer.readyState != 4 loop is 15 seconds slow
Feb 06, 2017 09:02 PM|bruce (sqlwork.com)|LINK
as your counter forces a min 15 second delay, it can never be quicker than 15 seconds. you could use the onreadystatechange event
;
Contributor
2853 Points
1372 Posts
Re: mImageViewer.readyState != 4 loop is 15 seconds slow
Mar 09, 2017 08:12 PM|adamturner34|LINK
How do you handle a failure to load and a reasonable time to notify the user of a problem?
All-Star
48280 Points
17983 Posts
Re: mImageViewer.readyState != 4 loop is 15 seconds slow
Mar 09, 2017 08:35 PM|PatriceSc|LINK
Hi,
I would try https://www.w3schools.com/jsref/event_onerror.asp (not sure which kind of error you want to report).
Not directly related but if youe have to keep your current approach, setInterval might be better.