Ajax can bring a much more responsive and intuitive feel to web applications. However, many times developers overlook error cases when using Ajax. What if the request fails? In one particular case a user’s session may have timed out before they made an Ajax call. This post describes one such way of handling this in a somewhat friendly way.
(more…)
Posts Tagged ‘ajax’
Handling Session Timeouts (and other errors) using Ajax
Released January 11th, 2008Online Vs Offline Applications: Everything old is new again
Released March 28th, 2007Everyone has probably noticed this already but the old is new again cycle for “online” desktop apps has been shortening at a rapid pace. Everywhere you turn you see people talking about offline and online apps and what should be online vs offline. If you take your time machine back you would see something like the following timeline:
- 1970s 3270
- 1980s X terminal
- 1990s Java applets
- 2000 Flash
- 2005 Ajax
Up until about 2000 it was taking 10 years to cycle from “we want everything on our desktop” to “we want everything on the server”. Now the cycle seems to have sped up to every year and then to constant. A couple recent examples of new faces on this old idea are Adobe’s Apollo and Joyent’s Slingshot.
Fundamentally not much has changed from the 1970s. The goal is to centralize computing resources into one place (in the simple view of things) and make issues like software deployment easier.The main difference now is that the industry has come to the point where there isn’t any turning back and everyone has bought on to the need and usefulness of online apps. The main sticking point seems to be finding a way to resolve issues that come up from users being disconnected from time to time. I’ll bet that one won’t be fully resolved until you have connectivity anywhere and everywhere you go.
IE7 adds native XMLHTTPRequest object
Released October 26th, 2006The recently released IE7 supports a native XMLHTTPRequest object. On the surface this can be considered a good thing and should be commended. However, to the people that erroneously (in hindsight) assumed that…
window.XMLHttpRequest == ! (not) IE
…they are in for some strange behavior (here, here, here, and here for example).
The problem occurs when the code is optimized for non-IE browsers and does not recreate the XMLHTTPRequest object on each event. Back when “window.XMLHttpRequest == !IE” was true, this code worked as expected: IE browsers created a new XMLHttpRequest object on each event and non-IE browsers reused the same XMLHttpRequest object. Now IE7 will correctly process the first event but then fails on the second (and subsequent) requests because you still can’t reuse XMLHttpRequest objects.
We chose to just remove the optimization all together and recreate the object on each event for all browsers. Others may wish to come up with some other check that will allow them to keep it.
AJAX file upload progress for Java using commons fileupload and prototype
Released April 2nd, 2006This has been done before with PHP (AJAX upload progress meter for PHP) etc but I needed something a little different because I wanted to upload a file and then have it loaded into a database. I looked around and found that someone had already made something that used the commons file upload package to do the upload part (AJAX Upload progress monitor for Commons-FileUpload Example). It wasn’t exactly what I was looking for but it a good start.
To understand the way this works I think it is easiest to break it down into parts:
- A file upload extention that counts bytes as they are uploaded
- An interface that monitors the progress of something running on the server
- AJAX to pull the monitoring into the current screen