Fix asynchronous ajax call error