startpoint
Active Member
I create json array and send to user_ajax.php with this code in form_XX.js file:
This is my function in user_ajax.php with needed query:
In this way all $data_id2 are merged.
How to change my code that value in $data_id2 to be separated with comma to get the query?
I tried many variants, but no luck.
JavaScript:
var rows_array_data = new Array();
jQuery(".repeatGroupTable .fabrikSubGroup").each(function() {
rows_array_data.push(
data_id
);
}
var data_id = rows_array_data;
var url = "index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=my_function&data_id=" + data_id;
new Request({url:url,
dataType:'json',
onComplete:function(r){
var result = jQuery.parseJSON(r);
}
}).send();
This is my function in user_ajax.php with needed query:
PHP:
public function my_function()
{
$db = JFactory::getDbo();
$app = JFactory::getApplication();
$input = $app->input;
$data_id = $input->get('data_id', '');
$data_id2 = json_decode($data_id, true);
$query = $db->getQuery(true);
$query = 'Select `column1` from `table_name` where `id` IN (' . $data_id2 . ')';
$db->setQuery($query);
$result = $db->loadResult();
}
In this way all $data_id2 are merged.
How to change my code that value in $data_id2 to be separated with comma to get the query?
I tried many variants, but no luck.