【发布时间】: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