Nature of the ac conductivity of ionically conducting crystals and glasses