A proper handling of Ajax requests