Same as the other one but with a master ajax function and using firebase.