Refactor ajax calls with defaults