Ajax on codeigniter 4 |
Hey guys, how are you?
I´m trying to use ajax on my ci4 application, but is not working. I want the select boxes changing according the countries and states selected. Please, some help? .js ________ $( ".pais" ).change(function() { var id_pais= $("#pais").val(); var base_url= "<?php echo base_url();?>"; $.post(base_url+'/index.php/estado/getEstado', { id_pais : id_pais },function (data) { $("#estado").html(data); $("#estado").removeAttr('disabled'); }); }); ________ Model ________ namespace App\Models; use CodeIgniter\Model; class EstadoModel extends Model { //Atributos de configuração protected $table='estado'; protected $primaryKey= 'id'; //Metodo GET public function getEstado($id_pais){ return $this->asArray()->where(['pais' => $id_pais])->first(); } } ________ Controller ________ use App\Models\EstadoModel; class Estado extends BaseController { public function getEstado() { $id_pais= $this->request->getVar('id_pais'); $model = new EstadoModel(); echo $model->getEstado($id_pais); } } ________ Note: Error code 403 to ajax response (I see this in the inspect element on my browser - Network). |
Messages In This Thread |
Ajax on codeigniter 4 - by Alexcodeig - 04-14-2020, 06:33 AM
RE: Ajax on codeigniter 4 - by ci4hell - 04-15-2020, 03:05 PM
RE: Ajax on codeigniter 4 - by InsiteFX - 04-16-2020, 03:34 AM
|