Separated ajax code from php functions for testing