Ajax requests functioning (not correctly, but I'm getting back error messages)