switch period with ajax