CodeIgniter Forums
Routing POST instead post - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Routing POST instead post (/showthread.php?tid=91623)



Routing POST instead post - pippuccio76 - 09-07-2024

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]


RE: Routing POST instead post - ozornick - 09-07-2024

Use is() 
https://codeigniter4.github.io/userguide/incoming/incomingrequest.html#is
I didn't go into details, AJAX probably ignores the case


RE: Routing POST instead post - kenjis - 09-07-2024

Are you really using CI 4.5+?