I have a jQuery function that gets data from a form and puts it as a string (for now) into an #content.
$(document).ready(function() {
$('form').submit(function() {
var results = $(this).serialize();
var url = '<php? echo JURI::base(); ?>index.php?option=com_mls&task=ListData&' + results;
$('#content').html(url);
return false;
});
});
So, I know how to build the query string from the form.
I have a task in my controller that runs a mySQL query string from the URL.
function ListData()
{
error_reporting(E_ALL);
$db =& JFactory::getDBO();
$sort = JRequest::getVar('sort');
...some other stuff...
$query = [some big nasty thing]
$db->setQuery($query);
$array = $db->loadRowList();
return $array;
}
So I know how to query the mySQL DB and get an array().
Then, I have a PHP script that pulls the array data into HTML format:
<?php
$array = $this->disparray;
foreach($array as $key => $value){
$mlsnum = $value['1'];
...some other data gets....
echo '<div>' . $mlsnum . '</div>';
}
?>
Here’s where I’m stuck. I don’t know how to get the URL query from jQuery to the controller task and then get the array() returned by that task into the PHP script which would build the HTML and then get AJAX/jQuery to put that data into #content.
Action is going on in 3 steps.
First ajax call view.raw.php then you load/add/delete some data from model, and customize it as you want. Then you print it in JSON format – send it back to ajax, and then ajax put that into html.
this will communicate with
/com_mls/(default_view)/view.raw.php
in there, you should probably do something like
….etc….
}