我在 Joomla 中的 AJAX 连接有问题。
AJAX
$(document).ready(function() {
var results = $('#hidden').serialize();
var url = '<php? echo JURI::base(); ?>index.php?option=com_mls&view=list&format=raw&' + results;
$('#test').html(url); //Just to see that the string is working.
$.ajax({
url: url,
success: function(){
alert('success');
},
error: function(){
alert('failure');
}
});
});
Joomla 模型view=list
:
function ListData()
{
error_reporting(E_ALL);
$db =& JFactory::getDBO();
$sort = JRequest::getVar('sort');
$pstart = JRequest::getVar('pstart');
$plimit = JRequest::getVar('plimit');
$hprice = JRequest::getVar('hprice');
$lprice = JRequest::getVar('lprice');
$city = JRequest::getVar('city');
$zip = JRequest::getVar('zip');
$bdrms = JRequest::getVar('bdrms');
$bths = JRequest::getVar('bths');
$query = "SELECT * FROM " . $db->nameQuote('#__mls') . " WHERE 1=1 ";
if ($zip != null || $city != null || $bdrms != null || $bths != null || $hprice != null || $lprice != null){
$firstand = "AND ";
}
$clauses = array();
if ($zip != null) {
$clauses[] = "MSTZIP = " . $zip;
}
... a bunch of IF statements for building query...
$query .= $firstand . implode(" AND ", $clauses) . $orderby . $pages;
$db->setQuery($query);
$table = $db->loadRowList();
return $table;
Joomla 视图:
function display($tpl = null)
{
$model = &$this->getModel();
$array = $model->ListData();
$this->assignRef( 'disparray', $array );
parent::display($tpl);
}
在我能走路之前跑,我只是想让 AJAX 显示success
。它不是。我不知道错误在哪里,也无法得到任何错误报告来帮助我。有任何 AJAX/Joomla 精明的人伸出援手吗?