Fix incorrect type detection when ajax + json are available.

Make ajax happen after content-type negotiation so that when jQuery
talks to CakePHP the requests don't get marked as ajax and instead get
marked as json.