Fix bug where keeps making Ajax requests