Improved ajax functions.