Problem sending data from ajax to controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem sending data from ajax to controller (/showthread.php?tid=59235) |
Problem sending data from ajax to controller - El Forum - 09-09-2013 [eluser]bigmac90[/eluser] Hey Guys I wonder if anyone can help me. I'm trying to send multiple inputs from the view to my controller from a .js file using the $.ajax function. However, the only problem is my data isn't being going over to the controller. My JS Code: Code: $('#bttnSubmit').click(function() { My Controller Code Code: function ajax_test() { Does anyone know whats wrong?? Problem sending data from ajax to controller - El Forum - 09-09-2013 [eluser]CroNiX[/eluser] What happens when you manually go to http://localhost/ProjectSage/index.php/site/ajax_test? Problem sending data from ajax to controller - El Forum - 09-09-2013 [eluser]bigmac90[/eluser] I keep getting three error messages saying something like undefined $company, etc. With an echo "It Works". Problem sending data from ajax to controller - El Forum - 09-09-2013 [eluser]CroNiX[/eluser] Try using CI's input::post() method instead of using the global $_POST, which get's sanitized. So what does your console show when the ajax request is sent? Problem sending data from ajax to controller - El Forum - 09-09-2013 [eluser]ivantcholakov[/eluser] @bigmac90 Paste html code of the form. Problem sending data from ajax to controller - El Forum - 09-10-2013 [eluser]bigmac90[/eluser] hey guys thanks for the replys. @CroNiX, tried using the CIs input::post and still got the same result. @ivantcholakov, my code for the form looks like: Code: echo form_open(); |