AJAX POST requests containing complex JSON data structure sent to a controller fails with HTTP 500. The controller has an empty action configured to the POST route with
bundle exec hanami generate action web home#test --method=post
This AJAX fails:
$.ajax({
url: engineURL,
type: ‘POST’,
dataType: ‘json’,
data: {“info”: [“test”, [{x:0, y:1}]]},
async: false
});
Another real life example that fails is:
dataArr = Array.from(dataMap)
…
data: {“info”: dataArr},
But this one works:
$.ajax({
url: engineURL,
type: ‘POST’,
dataType: ‘json’,
data: {“test”: [{x:0, y:1}]},
async: false
});
It’s not a JS or JSON conversion issue as any of the above data structures may be stringified with JSON.stringify() without errors