Hi Bob & Fredrik,
This different session and token issues are really interesting (you just opened a way for a solution I'm looking for in another issue...).
But I'm not sure if this is the case here.
The only connection to the user is the access to the back-end and to the form in the front-end (limited to 'manager' group). I don't pull any user data.
I 'just' trying to chain two SELECT lists, each gets the data from a different table.
It works perfectly in the front-end, but not in the back-end.
The logic I use: main table gives me a reference id. Then I use jason.remote to send it to extra1 (using '&task=extra' . I don't define the extraid). Then I do a simple query to the second table, generate a select.genericlist using JHTML and send it back using json_encode.
This is the code I wrote in the Form JavaScript field:
<?php
$document =& JFactory::getDocument();
$script = "
window.addEvent('domready', function() {
$('artist_id').addEvent('change', function() {
//e = new Event(e).stop();
var subject_container = $('subject');
var aid = $('artist_id').value;
var url = '".JURI::base()."index2.php?option=com_chronocontact&chronoformname=photosbe&task=extra&format=raw';
subject_container.innerHTML = 'Working on the subject list...';//temporary progress message
var jSonRequest = new Json.Remote(url, {
onComplete: function(r) {
subject_container.innerHTML = r.html;
}
}).send({'aid':aid});
});
});
";
$document->addScriptDeclaration($script);
?>
And this is the code in Extra code 1:
<?php
$json = stripslashes($_POST['json']);
$json = json_decode($json);
$db =& JFactory::getDBO();
$query = "
SELECT `id`, `subject`
FROM `#__aa_subjects`
WHERE `artist_id` = ".$db->quote($json->aid).";";
$db->setQuery($query);
$subjects = $db->loadObjectList();
$options = array();
foreach( $subjects as $subject ) {
$options[] = JHTML::_( 'select.option', $subject->id, $subject->subject );
}
$list =& JHTML::_( 'select.genericlist', $options, 'subject_id', null, 'value', 'text', '', 'subject_id' );
if( !$list ) {
$response['html'] = '';
}else{
$response['html'] = $list;
}
?>
I looked at the switch 'extra' > then 'doextratask function' > then doExtra function which all are simple and straight forward, and couldn't see why the URL should be different when calling it from the back-end.
Emanuel.