I am sending a POST ajax call like this:

var request = {
    option    : 'com_ajax',
    module    : 'mod_test',  // to target: mod_test
    method    : 'Test',  // to target: function TestAjax in class modTestHelper
    format    : 'raw',
    data      : {a: [], b: {}, c: [0], d: [null]}
$.ajax({method: 'POST', data: request})
// .success( ...yatta yatta

I am receiving with:

$data = JFactory::getApplication()->input->post->get('data', array(), 'array');

However, the passed empty subarray (a) and subobject (b) are purged before reaching my php script. So, the contents of $data is ['c'=>'0', 'd'=>['']]. In other words, when I call isset($data['a']) or isset($data['b']) they evaluate as false.

For my module, I ended up passing the string 0 to represent an empty array, but my code would be tidier if I was permitted to pass an empty array to php. (For my project, the first level has a known number of elements, only the subarrays are dynamically generated.)

  1. Is this a bug, a feature, and/or a known behavior?
  2. Am I able to adjust my JFactory... line to accept empty subarrays?

I did get some insight but not a complete solution from these related answers:

I am using Joomla 3.8.6

1 Answer 1


If you dumped the $_POST in your helper's ajax method you would see that those empty arrays don't hit the server. Joomla's input object is entirely dependent on retrieving the values from $_POST.

JQuery ajax doesn't pass empty arrays, see this for example further reading: https://stackoverflow.com/questions/9397669/jquery-ajax-jsonp-how-to-actually-send-an-array-even-if-its-empty

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.