These two variables don't feel right. If you've got logic that requires storing state (e.g. like these variables) you should probably look at moving this logic into a class so that it can all be encapsulated and you don't have ref and jsonUser as variables in the window namespace.