Fix possible error on ajax request