Handling url params in ajax calls with functions and objects