Generic ajax function.