AJAX-Tips Tutorials
AJAX-TipsTwo Ajax-Based Programming Tricks
Today we’ll take a look at two simple Ajax tricks that could enhance your web page.
Trick Number 1: More Ajax calls in a webpage
Every webpage could be loaded with Ajax calls so that there is a possible interactivity. However, if you’re thinking of loaded a webpage with different Ajax calls with more than two, you’re out of luck. Every webpage in almost any browser allows only up to two Ajax calls at the same time. That means you’ll have to work with two calls and that’s it.
However, there’s actually a good work around to this restriction:
Remember that a webpage will only allow two Ajax calls AT THE SAME TIME. That means the third or fourth Ajax call should not load at the same time with other programs. The trick is to delay the loading time of other Ajax calls. You can make the configuration on <body onload=”>. Delay the loading time of an Ajax call by inserting window.setTimeout(”ajaxcall()”, 400);. You may have to specify each call so that each program will have to load. That’s only a minor inconvenience of you’re planning to load more than two calls. Just remember to give your UI enough time to load. Think of Gmail as the program loads in the e-mail and then the contact list. There is a delay so that interaction between two programs is possible. That is also ideal so that programs in the webpage will have better interaction.
Trick Number 2: Dealing with Multiple UpdatePanel
Considering that you already have more than two or three panels that are constantly being refreshed. That means the bandwidth requirement for each webpage is higher and will basically load slower. The reason why some developers wanted to have streaming interactivity is because of the function that they give to the webpage. But sometimes, there is no new information in an UpdatePanel that refreshing it is not worth it. Most developers just go with the idea of having the page refreshed so that new updates will be possible.
But there’s actually a trick where a page doesn’t necessarily refresh based on time but rather on function.
This could be done by changing the UpdateMode property of each UpdatePanel. In the UpdateMode, change the property to “conditional”. That way, the specific UpdatePanel will only change when something new in the specific part of the program will change. There is an additional benefit of doing this. The server will never have a hard time of updating every UpdatePanel.
These are the two configurations that you can easily do to your Ajax based webpage. The challenge is not on the client but actually on the server. Usually the challenge is only at the start of the configuration but once it gets done, everything will just work out according your specifications. The Ajax based webpage is a challenging work and even though it has been more than two years since the hype started, there are still tricks that we still do not know. More to come….
AjaxWith.com Offers
Sponsored Links
