[TYPO3-mvc] ajax, output json_encode()

Muriel le Pair typo3 at strangefruit.nl
Mon Nov 24 12:46:39 CET 2014


Hi,

I would like to send an ajax request and return it to the page as json.

/**
* action ajaxsubmit
*
* @return void
*/
public function ajaxsubmitAction() {
	
	//$this->view->assign('forms', $forms);
	
	$ajaxResponse = array(
		'success' => false,
		'message' => "test"
	);
	json_encode($ajaxResponse);

}

If I call the action with JavaScript TYPO3 is nagging that the template 
is missing what is strange because I did not assign a view 
($this->view->assign('forms', $forms);).

If I add an empty template Ajaxsubmit.html to the template folder, the 
error will disappear and the content of the template is returned to my page.

But I would like the json resonse instead.

The strange thing is that it works in another extension. I can't 
remember that I needed to do something special to prevent the template 
to be renderd and output the json with json_encode().

What am I missing?

--
kind regards,

Muriel le Pair



More information about the TYPO3-project-typo3v4mvc mailing list