Fix history AJAX script