Fixed some bugs in ajax calls.