changed ajax requests to send as json and implemented logging function