0
你好,我試圖做一個選擇動態CakePHP中,我使用的是Postgres y的這個錯誤動態相關選擇框使用Ajax的jQuery CakePHP的
GET http://localhost:8080/img/ajax-loader_mini.gif 404 (Not Found) jquery-1.3.2.min.js:12
(anonymous function) jquery-1.3.2.min.js:12
o.extend.each jquery-1.3.2.min.js:12
o.extend.clean jquery-1.3.2.min.js:12
o.fn.o.domManip jquery-1.3.2.min.js:12
o.fn.o.append jquery-1.3.2.min.js:12
o.fn.o.html jquery-1.3.2.min.js:12
$.ajax.beforeSend add:61
o.extend.ajax jquery-1.3.2.min.js:19
(anonymous function) add:57
o.event.handle jquery-1.3.2.min.js:19
(anonymous function) jquery-1.3.2.min.js:19
GET http://localhost:8080/soyasubrubros/getByRubro/1 404 (Not Found) jquery-1.3.2.min.js:19
o.extend.ajax jquery-1.3.2.min.js:19
(anonymous function) add:57
o.event.handle jquery-1.3.2.min.js:19
(anonymous function)
在我的外接
我有一些jQuery的我要的是發送他的控制器,並從那裏發送子類別列表添加我擁有它。 add.ctp
**<div class="soya form">
<h3>Empresas Registradas para Adquisición de Grano</h3>
<?php echo $this->Form->create('SoyaClienteDerivado');?>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<fieldset>
<?php
echo $this->Form->input('soya_rubro_id', array(
'options' => $rubros,
'id' => 'PostRubroId',
'empty' => '--Porfavor selecione--','label' => 'Seleccione rubro'));
echo $this->Form->input('soya_subrubro_id', array(
'id' => 'PostSubrubroId',
'empty' => '--Porfavor selecione--','label' => 'Seleccione subrubro'));
echo $this->Form->submit('Agregar Cliente', array('class' => 'form-submit', 'title' => 'Presione aqui para agregar datos'));
?>
<script>
$("document").ready(
function() {
$('#PostRubroId').bind('click', function()
{
$.ajax({
type: "GET",
url: "/soyasubrubros/getByRubro/"+$(this).val(),
beforeSend: function() {
$('#PostSubrubroId').html('<div class="rating-flash" id="cargando_div">Cargando <img src="/img/ajax-loader_mini.gif"></div>');
},
success: function(msg){
$('#PostSubrubroId').html(msg);
}
});
});
}
);
</script>
</fieldset>
<?php echo $this->Form->end(); ?>
</div>**
這是類別列表的發電機
class SoyasubrubrosController extends AppController {
public $components = array('Session','RequestHandler');
public function getByRubro($id = null) {
$this->layout = 'ajax';
$this->loadModel('SoyaSubrubro');
$subcategorias = $this->SoyaSubrubro->find('list',array('conditions' => array('SoyaSubrubro.soya_rubro_id' => $id), 'fields' => 'subrubro'));
$this->set('listado_subcategorias',$subcategorias);
}
}
這裏就是我想要生成列表
class SoyaclientederivadosController extends AppController {
public $components = array('Session','RequestHandler');
public $uses = array('SoyaClienteDerivado','SoyaRubro','SoyaSubrubro');
public function add()
{
$this->loadModel('SoyaClienteDerivado');
$this->loadModel('SoyaAsociaciones');
$this->loadModel('Ciudad');
$this->set('asociaciones', $this->SoyaAsociaciones->find('list', array('fields'=>array('id','nombre'))));
$this->set('rubros', $this->SoyaRubro->find('list', array('fields'=>array('id','rubro'))));
$this->set('ciudades', $this->Ciudad->find('list', array('fields'=>array('id','nom_ciudad'))));
if ($this->request->is('post')) {
$this->SoyaClienteDerivado->create();
$this->request->data['SoyaClienteDerivado']['user_id'] = $this->Auth->user('id');
$this->request->data['SoyaClienteDerivado']['razonsocial'] = strtoupper($this->request->data['SoyaClienteDerivado']['razonsocial']);
$this->request->data['SoyaClienteDerivado']['nombre_com'] = strtoupper($this->request->data['SoyaClienteDerivado']['nombre_com']);
if ($this->SoyaClienteDerivado->saveAll($this->request->data)) {
$this->Session->setFlash(__('La informacion fue guardada.'));
return $this->redirect(array('action' => 'index'));
}
}
}