Additional hardening for ajax requests. Relates to #353.