fix race condition when socket.io message arrives before ajax