Added retry function for ajax calls