Added timeout protection to Ajax