473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

browser resends ajax request?

jhardman
3,406 Expert 2GB
I have a web app that updates a very large file. processing time takes around 45 seconds (and this is good. there might be ways to trim that down, but it is seriously a huge file). I use (old-school) ajax (not jquery) to call a web service that runs through the file, it checks for errors and updates a database. everything seems to be working EXCEPT that the browser keeps re-sending the ajax request every 30 seconds if it doesn't get a response. and my web server just starts a new thread each time.

Is this a behavior I can change or prevent?
Jan 11 '19 #1
4 2235
gits
5,390 Expert Mod 4TB
well - apparently this can happen under some circumstances like here:

https://blogs.oracle.com/ravello/bew...omatic-retries

or

https://stackoverflow.com/questions/...-post-requests

for me it seems that retrys can be valid behaviour thus i think somehow it should be handled by the software - in case the performance cant be improved to avoid the timeouts.
Jan 21 '19 #2
jhardman
3,406 Expert 2GB
re-worked it to run for ten seconds and respond back with how far it got, then set a timer in the javascript to call it again starting where it left off if it wasn't finished. seems pretty kludgy to me. is that what you had in mind?

Jared
Feb 6 '19 #3
gits
5,390 Expert Mod 4TB
well - for me it doesnt sound too kludgy - if its a process that a user starts in a frontend and you want him to wait for it and the process takes its time (and this time cant be improved) then its a good workaround and even something that you can use to inform the user about the progress so he/she isnt left alone with a indefinite requesttime.

Another way could be to use websockets or serverside events which would allow to push the finishing message to the client when everything is done. so you could send a request that starts the process and return with a 'process started' message directly. then - when the process is done - emit a message serverside to notify the client about it. This is a bigger re-work tho in most cases.
Feb 6 '19 #4
gits
5,390 Expert Mod 4TB
to add another option to it that i used when having such longer running processes: when it was possible i did split the process intentionally by using parallel XMLHttpRequests. basically 1 first request was just retrieving the max and then i did split that into smaller chunks by sending an offset along with the requests in parallel. Depending on how the backend can work with that this did lead to a performance increase (better user experience due to shorter wait time and less issues with timeouts) with such longer running processes. its similar to your solution - but a bit more predictable and it might be that the parallelism can improve overall processing time. In case its a locking operation (exclusive reading of a file or session or such) the first 'determining' request could prepare the parallel processing by splitting the file/DB already and tell the frontend how many requests will be needed to get all chunks - long story short - there are some ways (including yours) to handle such things and optimize them if needed.
Feb 8 '19 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: petermichaux | last post by:
Hi, Is it possible for an AJAX request to be left open for multiple responses? This could avoid repetitive polling of the server. Thanks, Peter
5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
0
by: arunprabu | last post by:
Hi, I have a problecm with the AJAX request in my webpage. I have some filters on top of the page. I have a submit button and an empty div below the filters. Some of the filters have ajax...
3
by: Simon | last post by:
I have the following code in Javascript which is creating and sending an XMLHttpRequest . <code> var xmlHttp; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlHttp = new...
1
by: nikki.farrah | last post by:
Hi all, this is my first time posting so any help is appreciated! I am doing a simple AJAX request to our server, and I would like the cursor style changed to 'wait' when the user clicks a button...
7
by: Sebarry | last post by:
Hi, I have a Javascript function that creates an Ajax Request object in order to retrieve data from a database using a PHP script. The Javascript function is invoked by another Javascript function...
3
by: mentor | last post by:
When user is authenticated, the server store "UserName" in session. Then throug ajax, the user request another page which require authentication. How the ajax request tell the server that one has...
11
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit (using .net version 3.5) is closed before the Ajax enable controls complete loading, then IE locks up. Does it in both IE7...
2
Frinavale
by: Frinavale | last post by:
I have a JavaScript class that displays a partially-opaque div over top of the content of another div when an Ajax request is sent to the server. When the request returns, the JavaScript class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.