Providing user feedback on background operations
Posted on | September 4, 2013 | No Comments
The simplest method for implementing this is to change the users’ mouse cursor. This can be implemented by adding a class to the body that changes the users cursor when you start the background operation, and remove the class when the background operation completes.
In the example of an ajax operation using jQuery:
[javascript]
$.ready(function(){
//when user changes the drop-down option…
$(‘form select’).change(function(){
//… and add the ajax class to the body …
$(‘body’).addClass(‘ajax’);
//… do an ajax call to get the next lot of drop-down filters.
var value = $(this).parent().serialize();
$.ajax({
type: “POST”,
url: “/ajax-search”,
data: value,
//when the ajax function returns…
success:function(data) {
//…do something with the search form
//…
//… and remove the ajax class last.
$(‘body’).removeClass(‘ajax’);
}
});
});
});
[/javascript]
So that adds the class to our website, this is the little bit of css you need to change the users’ cursor:
[css]
body.ajax, body.ajax * {
cursor:progress;
}
[/css]
And that is it! See it in action
Conclusion
By adding a little bit of feedback to the user you reduce the frustration experienced when the website “stops” for a bit.
Posted By:Richard Parnaby-King