public function flashmsg() {
		Configure::write('debug', 0);
		if (!$this->request->is('ajax') || !$this->request->is('post') ||
			!$this->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [];
		$dataDefault = [
			'result' => false,
			'key' => null,
			'messages' => [],
		];
		$keys = $this->request->data('keys');
		$delete = (bool)$this->request->data('delete');
		if (empty($keys)) {
			$data[] = $dataDefault;
			$this->set(compact('data'));
			$this->set('_serialize', 'data');

			return;
		}
		$keys = (array)$keys;
		foreach ($keys as $key) {
			if (empty($key)) {
				$key = 'flash';
			}

			$dataItem = $dataDefault;
			$dataItem['key'] = $key;
			if ($delete) {
				$dataItem['result'] = $this->FlashMessage->deleteMessage($key);
			} else {
				$messages = $this->FlashMessage->getMessage($key);
				$dataItem['messages'] = $messages;
				$dataItem['result'] = !empty($messages);
			}
			$data[] = $dataItem;
		}

		$this->set(compact('data'));
		$this->set('_serialize', 'data');
	}