Joomla コンポーネントに AJAX を組み込む方法について詳しく調べましたが、手順が足りないように感じます。これが私がこれまで持っている構造です:
AJAX 呼び出し
var url = "index.php?option=com_mls&task=ListData&format=raw";
$(document).ready(function() {
$('#submit').click(function() {
$.ajax({
url: url,
type: "POST",
dataType: 'json',
success: function() {
$('#content').load('data.php');
}
});
});
});
data.php
$array = [! I need a way to get the results from controller.php !]
foreach($array as $key => $value){
echo "<div>" . $value['2']; "</div>
}
controller.php
function ListData()
{
$query = [! A bunch of "JRequest::getVar" that builds the query !];
$db->setQuery($query);
$array = $db->loadRowList();
echo (json_encode($array));
}
私が見逃しているステップは、コントローラータスクから#content
ノードにデータを取得することです。