Update after preliminary support from @jamesgarrett and @Lodder...
I am just not getting the desired response string.
Here are my files (stripped down even farther):
administrator/modules/mod_filefinder/mod_filefinder.php
defined('_JEXEC') or die;
require_once dirname(__FILE__) . '/helper.php';
$filefinder = new modFileFinderHelper();
require JModuleHelper::getLayoutPath('mod_filefinder');
administrator/modules/mod_filefinder/helper.php
class modFileFinderHelper
{
function __construct() {
$this->currentdirectory = basename(JPATH_BASE);
}
public function FileFinderAjax() {
$data = JFactory::getApplication()->input->post->getArray([]);
$path = $data['data']['path'];
?><script>console.log('<?=$path?>');</script><?php
echo "hello $path";
JExit;
}
}
administrator/modules/mod_filefinder/tmpl/default.php
defined('_JEXEC') or die;
JHtml::_('jquery.framework');
JHtml::_('script', 'administrator/modules/mod_filefinder/ajax.js');
echo "<div id=\"filefinder_container\">{$filefinder->currentdirectory}</div>";
administrator/modules/mod_filefinder/ajax.js
jQuery(function($) {
function loadContent(path) {
console.log({path: path});
var request = {
option : 'com_ajax',
module : 'filefinder', // to target: mod_filefinder
method : 'FileFinder', // to target: function FileFinderAjax in class modFileFinderHelper
format : 'raw',
data : {path: path}
};
console.log(request);
$.ajax({
method: 'POST',
data: request
})
.success(function(response){
console.log('response: '+response);
});
}
console.log('onload, calling ajax with default path value: '+$('#filefinder_container').html());
loadContent($('#filefinder_container').html());
$('#path').on('change', function() {
console.log('change event triggered, calling ajax with path value: '+$(this).val());
loadContent($(this).val());
});
});
This is my console.log data:
So let me try to ask this differently.
What is the simplest file structure that will allow me to:
- Load an empty html structure.
- Send an AJAX call a single-purpose (build a json string) php file
- Receive the json response and distribute the json data into the html structure
Simple right? Please help.