0

I've been reading up extensively on incorporating AJAX into my Joomla component, but I feel like I'm missing a step. Here is the structure I have so far:

AJAX CALL

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));

}

The step I'm missing is getting the data FROM the controller task and into the #content node.

1 Answer 1

0

you can try this one:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.