Feature #20952 » 11819_v2.diff

Administrator Admin, 2009-09-16 16:33

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;
......
259 262
			echo $content;
260 263
		}
261 264
	}
265

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

  
276
					response = ' . json_encode($this->content) . ';
277

  
278
					/*]]>*/
279
					</script>';
280

  
281
		header('Content-type: text/html; charset=' . $this->charset);
282
		echo $content;
283
	}
262 284
}
263 285

  
264 286

  
(2-2/2)