Fixing AJAX request bug