AJAX ARRAY - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: AJAX ARRAY (/showthread.php?tid=76596) |
AJAX ARRAY - andwise - 05-30-2020 Hello there. I'm from Turkey. I use google translate because i don't speak english. I am sending an array to the Controller with AJAX. There are 3 different IDs in the array I sent. I will pull data from the database with these IDs, but I don't know how to separate them. Ajax Code: $.ajax({ Controller Code: public function o_getir() { Model Code: public function o_get2($data) { IDs in Array The data I want to bring from the database. The data of each ID must be in different arrays. RE: AJAX ARRAY - InsiteFX - 05-31-2020 You need to use json_decode to convert the json array into a php associated array. Then you can get the values you need. RE: AJAX ARRAY - andwise - 05-31-2020 I was able to export the data to the array variable in the model file. My Model Code: public function o_get2($data) { Print: Array ( [0] => Array ( [0] => S [1] => M [2] => L [3] => XL ) [1] => Array ( [0] => Kırmızı [1] => Sarı [2] => Yeşil ) ) but i can't print it on controller. Controller??? Code: public function o_getir() { RE: AJAX ARRAY - InsiteFX - 06-01-2020 Maybe this will help you. How to Handle AJAX request on the Same Page – PHP |