Please send any feedback on admin@ajaxline.com.
If you want to share your experience and post article on Ajaxline just e-mail it to us and we publish it.
Oliver Steel tells in his blog how to manage with busy cursor in Javascript. He writes:
«What’s wrong with this function? (Hint: it’s meant to execute periodically on a JavaScript page.)
function updateExpirationText() {
var now = new Date;
products.forEach(function(item) {
var expiresDate = item.expiresDate || Date.parse(item.expires),
remaining = expiresDate – now,
text = remaining < 0 ? ‘expired’ : msToDuration(remaining);
$(‘item-’ + item.id + ‘ .time-remaining’).text(remaining);
});
}
It’s a trick question. Maybe nothing’s wrong. But if products can get very long, or if the msToDuration is very slow, you’ve locked up the UI for a long time. At best, this makes for sluggish response; at worst, the page that contains this will trigger a “script running slowly” error, and the user will likely abort all the JavaScript on the page.
If this computation only needs to run once, and when (or before) the page loads, you can do it on the server. But often a computation depends on some aspect of the client state, that isn’t known when the page is requested. In this example, the computation depends on the current time (and the current time keeps changing). In another case, the computation might depend upon the values of some controls or other widgets on the page — if we’ve gone all AJAXy, and want to show the user an instant response, even if that means some client-side computation.»
You can read the full version of article on Oliver Steel Blog.