Better security check for ajax events