Monday, July 31, 2006


Here's a fantastic JavaScript site. Look at his Ultimate Drop Down Menu! I have his book but haven't started to read it :(

Saturday, July 15, 2006

AJAX File Uploader

In an administrative interface of my Photo Gallery I'm using XMLHttpRequest to send all the information about picture being uploaded to a server and check its validity. (I used synchronous mode because at the time I programmed it all the AJAX heap wasn't there yet). I wanted to upload files with the help of XMLHttpRequest without page reloading, but I couldn't find a way to do that. There were some proprietary IE solutions and proprietary Mozilla solutions, but no common one. To upload file, HTML form must set ENCTYPE="multipart/form-data" (a default value is "application/x-www-form-urlencoded") and it seems that XMLHttpRequest cannot do that.
The solution I found was to check everything and send a data to server using XMLHttpRequest without page reloading, then to upload a picture using conventional FORM POST operation inside an IFRAME.
It looks like that there is nothing new that and this Indian guy uses similar approach with his "AJAX File Uploader" class.

Although.... let's investigate all results of corresponding Google search.

Friday, July 14, 2006

I created a new sub domain for learning and testing new [Web] technologies. I will add some examples of using various Web-related technologies there.

I'm starting to educate myself with an unusual strength :) I fell behind once again.

JavaScript - version 1.7 is about to be released

The cool feature of JavaScript is that it allows to check if a function is defined and create your own version otherwise, adding it to a prototype of an object. For example, JavaScript's String object lacks trim() method. shows how to fix it.

Yesterday I found a cool library which implements new 1.6 -1.7 methods of arrays in a similar manner: when your browser's JavaScript will become 1.6 and then 1.7 your code won't break, but will automatically use built in methods instead of custom ones.

AJAX - it's a pleasure! It's a coming way of making really interactive Web applications which communicate with a server without page reloading. There are plenty of books on this issue (and I bought almost all of them) but one really stands apart: Ajax Design Patterns by Michael Mahemoff
His site is

PHP. Version 5 is a full-fledged OOP language with a lot of convenient and powerful libraries developed for it. You normally can do anything you can do in ASP.NET, for example, but in a much easier and more flexible way. I was surprised when I started to work with PHP on how much better, bigger, and more convenient is its standard library and common user-developed libraries than ones used in ASP. Open Source rules!

I'm going to learn and pass Zend PHP Certification

Design Patterns
It's a cool thing, if you learn it with an excellent Head First Design Patterns (thank you, Andrew, for pointing me to it) written by by Elisabeth Freeman and Eric Freeman

MySQL 5.1 and PostgreSQL - I need to jump into that.

I still need to get heavily involved into ASP.NET and C# development. While I like C#, I think that ASP.NET approach suffers greatly from usual Microsoft's design flaw: it's too big, it's too predefined, so when you develop a real application you spend more time on finding workarounds for built-in events and other features which work the way they were designed, but not the way your application's business logic dictates.

Thursday, July 06, 2006

Eric's weblog - Will Ajax get another bad rap? Yahoo worm

Here's an interesting set of articles about Ajax security ("Samy worm").

Also, Eric showes there a workable soliution for implementing timeout warnings for session expiration.

Javascript Closures

Javascript Closures - an article by

Closures and IE Circular References and What makes closures interesting?

Wednesday, July 05, 2006

How to implement timeout warnings for session expiration?

Hi everybody!
My bank's Web site has a neat feature: after some period of user inactivity it displays a JavaScript confirmation window asking to click a button to stay connected. If user clicks a button within some short time interval, he/she stays connected. Otherwise, after closing a confirmation window user is forcefully redirected to logout screen.

I think it's a nice user-friendly feature. It's too often when users of my ASP applications enter a bunch of data to a form, then went somewhere, return and click on a "Submit" button just to realize that session was already expired and all data entered was lost.

Question: how to implement that feature (wit ASP or PHP back-ends)?
ASP provides Session_OnEnd event (PHP does not), but it gives no help: I don't think you can refresh a session at the time this event is fired, and you cannot interact with user from inside this event handler.
I can imagine running JavaScript timer on each page. When it decides that session is about to expire, it displays a warning. In case user says he wants to continue, JavaScript connects to a server using XMLHttpRequest and runs some script there, which automatically resets a session expiration time. A response from a server should tell JavaScript to reset a timer.
But what if there are more than one browser window, frame, or iframe open for this site? Especially for multiple windows we need a way for server to initiate counter reset on all client windows when one of them is refreshed. (By the way, it isn't implemented correctly on my bank's website). We could make one more XMLHttpRequest to a server just before displaying a coming expiration warning. It will ask a server for actual expiration time and reset this window's timer as necessary. But for server to know expiration time it must be reset during each page server script running and saved ... in a session variable.
Another solution which comes to mind would be to use server-push technology to reset all necessary client timers. There are some interesting news about it there.

It would be nice to implement timer on a server instead of client JavaScript... but I have no idea of how to do it in ASP or PHP.

What do you think about all that?