Feature #20952 » 11819.diff

Administrator Admin, 2009-08-28 22:35

View differences:

typo3/classes/class.typo3ajax.php (working copy)
142 142
	 * @return	void
143 143
	 */
144 144
	public function setContentFormat($format) {
145
		if (t3lib_div::inArray(array('plain', 'xml', 'json', 'jsonhead', 'jsonbody'), $format)) {
145
		if (t3lib_div::inArray(array('plain', 'xml', 'json', 'jsonhead', 'jsonbody', 'javascript'), $format)) {
146 146
			$this->contentFormat = $format;
147 147
		}
148 148
	}
......
186 186
			case 'json':
187 187
				$this->renderAsJSON();
188 188
				break;
189
			case 'javascript':
190
				$this->renderAsJavascript();
191
				break;
189 192
			case 'xml':
190 193
				$this->renderAsXML();
191 194
				break;
......
258 261
			echo $content;
259 262
		}
260 263
	}
264

  
265
	/**
266
	 * Renders the AJAX call as inline JSON inside a script tag. This is useful
267
	 * when an iframe is used as the AJAX transport.
268
	 *
269
	 * @return	 void
270
	 */
271
	protected function renderAsJavascript() {
272
		$content = '<script type="text/javascript">
273
						response = ' . json_encode($this->content) . ';
274
					</script>';
275

  
276
		header('Content-type: text/html; charset=' . $this->charset);
277
		echo $content;
278
	}
261 279
}
262 280

  
263 281

  
(1-1/2)