Improve ajax loader functionality