解决AJAX连接问题[关闭]

                <div class="grid--cell fl1 lh-lg">
                    <div class="grid--cell fl1 lh-lg">
                        This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,   or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making   this question more broadly applicable, <a href="/help/reopen-questions">visit the help center</a>.

                    </div>
                </div>
            </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2012-12-19 08:10:55Z" class="relativetime">7 years ago</span>.</div>
        </div>
    </aside>

I'm having an issue with my AJAX connection in Joomla.

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 model for 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 View:

function display($tpl = null)
{
    $model = &$this->getModel();
    $array = $model->ListData();
    $this->assignRef( 'disparray', $array );
    parent::display($tpl);
}

Run before I can walk, I'm just trying to get the AJAX to display success. It's not. I can't tell where the mistake is and can't get any error reporting to help me out. Any AJAX/Joomla savvy folks lend a hand?

</div>

Try the code below

jQuery.post('index.php',{
                'option'    : 'com_mls',
                'controller': 'controllerName',
                'task'  : 'taskName',
                'format'    : 'raw',            
                'results'   :  results                        
            }).success(function(result) { 
               alert('success');
            }).error(function() { 
                alert('error');
            });

In the controller you could have whatever the function you want(taskName). If you have any issues let me know

Needed to use developer tools to see where AJAX query string was trying to go. After that, I was able to determine the correct URL and class that needed to be accessed in the URL string.

//Removed '<php? echo JURI::base(); ?>'
var url = 'index.php?option=com_mls&view=list&format=raw&' + results;

Credit to Sajjan for help.