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に精通した人は手を貸しますか?