DevExpress Aspxcallbackpanel Client Side Timeout? - ajax

I've read plenty about how to handle Server-Side timeouts & errors during a Callback...
but what about Client Side timeouts?
here's the example.
Guy fills out a web form. Hits submit & the ASPXCallbackPanel does a PerformCallback.
But right then... his internet drops or his router burps.
In my app, the Callback panel never returns control back to the Webpage.. and the callback never completes.
Anybody know a Timeout settings on the Client side? or a way to abort a callback through Javascript?
thanks

If I were you, I would start a timer everytime a callback is sent to the server and refresh the page when the timer ticks. If the callback returns earlier, the timer should be stopped. This can be easily done using the ASPxGlobalEvents control.

Related

Flask AJAX: send interim data to front end during a route

I've made an app using Flask, that has a backend process that is initiated by the user.
When the user initiates the process, some data is sent to Flask via jQuery AJAX, which is then processed, and the results are returned.
This process can take between a few seconds and up to around a minute, so I have a 'please wait' modal on the front end while waiting for the AJAX response from the backend.
Is there a way I can send interim data to the front end, to update the 'please wait' modal, while the backend process is doing its thing?
The backed process performs iterations until it is satisfied. So ideally I would like to be able to display to the user how many iterations it has performed.
Initially I thought that there might be something within Flask's 'flash' message feature. But it seems that this relates more to redirects in a route, rather than AJAX calls to a route.
Any suggestions would be appreciated.
Cheers,
Hugh
Yes you can do it, but not with AJAX, becuse the HTTP comunication is only client to server, so you cant update asynchronously your clinent with HTTP, so you need to use other protocol. I highly recommend to use SocketIo, this protocol allows to you to send mensagens asynchronously from server to update your front, becuse this protocol persist the user in server. With this protocol(for example) you can make a chat room, like WhatsApp. for more information see Documentation SocketIo Flask Extension

Grails: server-to-client notification

I'm building a Grails app which queries several API's across the Web. The problem is that this queries are very time consuming and it is really annoying for the user to click one button and wait so much time without nothing changes in the page.
The basic architecture of my app is, when the user clicks the button, the client side performs an Ajax request with Prototype library to the server side. The server side, then, connects to the Last.fm API and retrieve a list of events. When the server side is finished populating the list with events it sends a JSON response to the client side which allows the client side to create markers for each event on a Google map.
What I want to achieve is, instead of waiting for all the events being retrieved from the API to send the JSON response, the server side sends a JSON response as soon as it retrieve one event, allowing the client side to populate the map while other events are yet being retrieved.
Any ideas how can I implement this? I read about the concept of Ajax Push but I'm not sure if it is what I need.
Thanks for the help!
There is no way to open a listening connection on the client that your server might connect to. Instead, what you need is a connection to the server that is kept alive and can be used to receive events. This way, you could directly return the "action" request and inform the client through your persistent event connection once the last.fm request was completed.
That said, the way I would implement is using ajax keep alive.
Take a look at cometd plugin.

Realitme via ajax, How to create an open connection to a non-blocking server like tornado etc?

When people create real-time web apps, they are leaving a ajax request open/long running.
how do they do this in javascript?
There is really no difference from a normal ajax request. A callback is associated with the XMLHttpRequest. Once the request is complete the callback is invoked. The difference is on the server-side where the request is held open until data is ready for the client, or a timeout occurs. On the browser side, the callback is invoked as each successive request is answered. The callback must process the data from the server and initiate another request. The request is handled asynchronously, so the browser is not blocked.
A really good example of the whole thing is the chat demo included in Tornado.

autocomplete through ajax

I want to suggest results using auto-complete. I need to send AJAX requests on each keystroke. For this I want to keep the HTTP connection open for few seconds and if something is typed within that period, I want to send the AJAX in that same connection. If nothing is typed in that period, I want to close the HTTP connection.
Background:
I already use typewatch plugin. But here the HTTP connections are made each time I send a request. I still want to improve the speed. I read in this thread http://www.philwhln.com/quoras-technology-examined#the-search-box that:
Quora uses persistent connections. A
HTTP connection is established with
the server when you start typing the
search query.
How can I do this with cross browser support? Is it just keep-alive?
You can't. Each request-response round trip is asynchronous, meaning that when it's sent, it waits for that particular request's response to return, then handles it.
What I think you want to do is prevent your script from hammering the server. To do this there are a variety of methods, but the most common is to use a keystroke timer. The timer waits a specified number of milliseconds after the user finishes typing before sending the request, containing the textbox's value, to the server.
If you're using JQuery you can use the TypeWatch plugin to do this. JQuery will also satisfy your cross browser requirements.
However, since you also want to do auto-complete, you may as well use the JQuery AutoComplete plugin which also has a keystroke timer built in, by default it's set to 400 millseconds. Click the OPTIONS TAB on this page to see what all the configuration options are that you can pass into the plugin.

AJAX synchronous (SJAX) on session restore

I have a large web page (classic ASP) with lots of information required from the user, so lots of inputs. The user's behavior is that he will fill in the information over time, analyze it and other time consuming processes before submitting. The problem is that even though the session timeout is set to a reasonable 30 minutes, often i get complaints that when submitting, the user gets the timeout message and loses all his work, all he filled in before. I thought it would be elegant to check on the submit event if the session is abandoned, in which case to have a login form appear. By using Ajax synchronous, for the session check, and for the login itself, the state of the web page will remain unaltered, allowing the user to continue with the submit after the session has been restored.
However, I've been reading about the perils of synchronous, and how it is recommended to avoid when possible. For me it seems that this is one of those cases when synchronous is required, but i didn't find anyone that has done this before.
I am looking for advice on whether this is a good course of action, using Ajax synchronous for a session restore.
Thank you.
There is no need to do a synchronous request here. You can cancel the form submission (return false or event.preventDefault() from the submit handler), start the asynchronous XMLHttpRequest to do the check, then in the AJAX response handler either display a message or restart the form submission (form.submit()) as appropriate.
I'd suggest 30 minutes is probably not a reasonable session timeout if it is causing these problems. A longer timeout, and/or having the form ping the server back to keep the session alive, might be a more convenient approach for users.

Resources