Handle ajax and nonajax posts.