Welcome Guest, Not a member yet? Register   Sign In
Routing POST instead post
#1

(This post was last modified: 09-07-2024, 07:08 AM by pippuccio76.)

hi , in the new version i have the error that action metod must be uppercase instead lowercase (POST,PUT,GET,DELETE instead of post,put,get,delete) , i have a problem with ajax request :
Code:
$.ajax({

                    url: "<?php echo base_url('/AjaxRequest/get_Clienti_sedi'); ?>",
                    method: "POST",
                    data: {
                        id_clienti: id_clienti,
                    },
                    dataType: "JSON",
                    success: function(sedi) {

                        var html = '';

                        for (var num_row = 0; num_row < sedi.length; num_row++) {

                            html += '<option value="' + sedi[num_row].id + '">' + sedi[num_row].nome_sede + '</option>';

                        }

                        $('#id_id_clienti_sedi').html(html);



                    },
                    error: function() {
                        alert("Chiamata fallita, si prega di riprovare...");
                    }

                });

in my controller :

Code:
if ($this->request->getMethod() === 'POST')
but the code dont go inside if ... because if i do :
Code:
            log_message('debug','get_Clienti_sedi NO POST '.$this->request->getMethod());



i have :

get_Clienti_sedi NO POST post in my log .

Why?

ps i dont understand how use code in this way... isn't better use [CODE]
tag ?[/code]
Reply
#2

Use is() 
https://codeigniter4.github.io/userguide...st.html#is
I didn't go into details, AJAX probably ignores the case
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply
#3

Are you really using CI 4.5+?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB