Make ajax request to right endpoint