Hola foreros, intento hacer una llamada Ajax en Symfony 1.4 pero cada vez que se hace click se regarga toda la página. Hay unos option, al hacer click sobre uno de ellos se envia en form:
Código PHP:
Ver original<?php use_helper('Javascript'); ?>
<div class="frameLeftContent"><?php echo image_tag("buttons"); ?><br />
<?php echo form_remote_tag
(array( 'loading' => 'Loading',
'complete' => 'Complete!',
'update' => 'frameRightContent',
'url' => 'main/getFlash',
), array("id" => "getFlash")); ?> <select name="file_selection"
style="width: 320px; height: 620px; overflow: hidden; margin-top: 10px;"
multiple="multiple" />
<?php foreach($list as $cat => $file):?>
<optgroup label="<?php echo $cat;?>">
<?php foreach($file as $object):?>
<option
onclick="changeImage('<?php echo $object->getDescription(); ?>'); document.getElementById('getFlash').submit();"
value="<?php echo $object->getConvertedName(); ?>"><?php echo $object->getPptName(); ?></option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
</form>
</div>
<script>
function changeImage(name)
{
document.getElementById('windowStatusBar').innerHTML = "Showing File: " + name;
return true;
}
</script>
La acción es:
Código PHP:
Ver originalpublic function executeGetFlash()
{
$fileName = $this->request->getParameter('file_selection');
$this->content = 'xxx';
$this->request->setParameter('content', $this->content);
if ($request->isXmlHttpRequest())
{
return $this->renderPartial('main/frameRightContent', array('content' => $this->content)); }
}
La función isXmlHttpRequest() devuelve siempre false.
JS se carga correctamente.
No hay otros errores de JS.
Nombres elementos, componentes etc, están ok.
Espero que alguien pueda echar una mano, gracias, salu2