0

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ノードにデータを取得することです。

4

1 に答える 1

0

あなたはこれを試すことができます:

$(document).ready(function() {
   $('#submit').click(function() { 
     var url = "index.php?option=com_mls&task=ListData&format=raw";
     $.ajax({
        url: url,
        type: "POST",
        dataType: 'json',
        success: function(data) {
            $('#content').html(data);
        }
    });
  });
});
于 2012-12-13T16:18:25.333 に答える