How to create basic ajax calls?

Hello Everyone,

I’m Robby and one of the newbies to Neos and this community. If this Post isn’t in the right place, please let me know where to put similar question in the future. Thanks in advance.

I’m working on neos 2.1.3 and have to develop my own package. This package needs some basic ajax calls and I can’t get my head around. Maybe some can help me with either a cool tutorial or some infos about my code.

I see that I need some changes in the routes.yaml

  name: 'packagename'
  uriPattern: 'GD-{action}'
    '@package': ''
    '@controller': 'Standard'
    '@action': 'getAjaxData'
    '@format': 'json'

on my StandardController I’ve added a public function

public function getAjaxDataAction($action){
  /*do some stuff*/
return json_encode($data);

my javascript:

 var ajaxUrl = 'GD-';
        $(function() {

             data: '&lookup=test',
             type: 'POST',
             url: ajaxUrl,
             dataType: "json",
             success: function(data) {
                 console.log("kam was zurück");

I’m getting an Error back from my Ajax Call which I couldn’t understand:

Exception while property mapping for target
type “mixed”, at property path “”: Could not find a suitable type
converter for “mixed” because no such the class/interface “mixed” does
not exist.

Can anyone help me? I just need a Function which can return me json-data!

Thanks a lot for your time

Sounds as if the $action does not have a correct @param annotation in your controller…

Hi Robby,

Your action should have some annotations.

 * @param string $action

The annotation will be parsed and should describe which format is expected. If nothing is documented ‘mixed’ will be used. The framework will convert incoming data to that format using a typeconverter. So maybe try the annotation above.

PS: if you don’t now how the ajax call should be built, use a viewhelper to generate the url + params (for testing) ->

Thank you very much!