Tuesday, November 8, 2011

High speeding technique for Ajax post

When you use this technique, your user feels as fast as client app.

The conventional method 
  1. Set onClick = 'update(this);' to element
  2. Post with update()
  3. Wait for callback function
  4. Update UI with callback function
→User has to wait for callback function.(S)he feels slow.

This technique
  1. Set onClick = 'update(this);' to element
  2. Before post with update(),update UI
  3. Wait for callback function
  4. If post is failed,reset UI and handle error with callback function
→User doesn't have to wait for callback function.(S)he feels fast.
#If app's updateing often fails and a user overlook errors and resetting UI, (s)he has discontent.

Best practice
Callback function works only for resetting UI and handling error so you can commonize it.

Note
The conventional method is popular method.Why?I think the reason is callback function is too convinient.
'Language defines thinking'--This is Sapir-Whorf hypothesis.I suggest that callback function defines programmer's thinking. 
In Fuzzy system,for example SNS,Game, you might want to use this technique.
Especially in Game,fast response is essential. 

No comments:

Post a Comment