【问题标题】:Joomla component with AJAX/jQuery populating #containers使用 AJAX/jQuery 填充 #containers 的 Joomla 组件
【发布时间】:2012-12-13 16:08:44
【问题描述】:

我一直在广泛阅读有关将 AJAX 整合到我的 Joomla 组件中的内容,但我觉得我错过了一步。这是我到目前为止的结构:

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 节点。

【问题讨论】:

    标签: php jquery mysql ajax joomla


    【解决方案1】:

    你可以试试这个:

    $(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);
            }
        });
      });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-10
      • 1970-01-01
      • 2017-11-30
      • 1970-01-01
      • 2012-07-27
      • 2016-03-19
      • 1970-01-01
      相关资源
      最近更新 更多