Hello.. I was trying to use fabrik user ajax from the wiki http://fabrikar.com/forums/index.php?wiki/user-ajax/
I want to make ajax call to retrive data from db then update to dropdown element (onload).
I've searched in this forum but i can't figure how to solve my problem.
My Code :
1. user_ajax.php
2. js in the dropdown element (javascript plugin onload)
1. Which should i use to process query in user_ajax function? loadAssocList() or loadObjectList() ?
2. How to get the return value from user_ajax function ? And how to process the value in js and generate it as dropdown?
Any help would be appreciated
Thanks!!
I want to make ajax call to retrive data from db then update to dropdown element (onload).
I've searched in this forum but i can't figure how to solve my problem.
My Code :
1. user_ajax.php
PHP:
<?php
defined('_JEXEC') or die('Restricted access');
class UserAjax
{
public function getPropinsi()
{
$db_sas = FabrikWorker::getDbo(false, 2);
$query = "SELECT DISTINCT propinsi FROM sas_master_kodepos ORDER BY propinsi ASC";
$result = '';
$db_sas->setQuery($query);
$result= $db_sas->loadAssocList();
echo $result;
}
}
2. js in the dropdown element (javascript plugin onload)
JavaScript:
var url = "index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=getPropinsi";
new Request({
method: 'get',
async: true,
url:url,
onComplete: function(response) {
alert(response);
Fabrik.getBlock('form_18').elements.get('sas_master_siswa_all___kodepos').update(response);
}
}).send();
1. Which should i use to process query in user_ajax function? loadAssocList() or loadObjectList() ?
2. How to get the return value from user_ajax function ? And how to process the value in js and generate it as dropdown?
Any help would be appreciated
Thanks!!