Welcome Guest, Not a member yet? Register   Sign In
Ajax 403 error
#1

HI , sorry for english , in my form , i want populate a select by searching value inserting a substring ( with like select ),

This is Jquery code :

Code:
<script>

$( document ).ready(function() {
   var stato=$("#id_class_stato_agenda_id option:selected").val();
    


    $("#id_class_stato_agenda_id").change(function() {
     var stato=$("#id_class_stato_agenda_id option:selected").val();
        
   
      if(stato=='1' ||  stato=='2'){
                $("#id_class_clienti_id").val('');
     }    
        
        console.log(stato);
    });
       
       
       
   $("#ricerca_cliente").click(function(){
       
       var ragione_sociale_getted = $("#ragione_sociale").val();
       var csrfName = '<?php echo $this->security->get_csrf_token_name(); ?>';
       var csrfHash = '<?php echo $this->security->get_csrf_hash(); ?>';
       
       $.ajax({
           type: "POST",
           url: "<?=base_url()?>index.php/clienti/ricerca_clienti_select",
           data: {
               ragione_sociale:ragione_sociale_getted ,
               csrfName:csrfHash
           },
           dataType: "html",
           success: function(msg)
           {
             $("#id_class_id_cliente").html(msg);
           },
           error: function()
           {
             alert("Chiamata fallita, si prega di riprovare...");
           }
       });
   });

});
</script>


This is  the controller :
this is the  controller function :

PHP Code:
   public function ricerca_clienti_select() {
 
       
        $csrf 
 $this->security->get_csrf_hash();
    
 
       $this->output->set_content_type('application/json')->set_output(json_encode(array( 'csrf' => $csrf)));
 
       
        if 
(!empty($this->input->post('ragione_sociale'))) {
 
           
            $ragione_sociale 
$this->input->post('ragione_sociale');

 
           $lista $this->clienti_model->recupera_by_name($ragione_sociale);

 
           foreach ($lista->result() as $row) {
 
               echo "<option value='" $row->id_clienti " '>";
 
               echo $row->ragione_sociale;
 
               echo "</option> ";
 
           }
 
       }
 
       
    


This is error :

jquery-3.2.1.js:9566 POST https://www.mysite.it/gest/index.php/cli...nti_select 403 (Forbidden)
 XHR failed loading: POST "https://www.mysite.it/gest/index.php/clienti/ricerca_clienti_select".
Reply


Messages In This Thread
Ajax 403 error - by pippuccio76 - 10-18-2017, 12:57 PM
RE: Ajax 403 error - by pippuccio76 - 10-19-2017, 04:05 AM
RE: Ajax 403 error - by PaulD - 10-19-2017, 10:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB