Access ajax data from the function and use it outside CI3 - 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: Access ajax data from the function and use it outside CI3 (/showthread.php?tid=87468) |
Access ajax data from the function and use it outside CI3 - janeiro - 04-23-2023 I'd like to add selected attribute to subcategory field in my form using ajax. Code below gets data about the book and the other populates subcategory field in form. How to access data from function edit_book so I could use it outside? I'm trying to find the solution for 8 hours now experimenting... PHP Code: /*populate subcats field on cat field change*/ RE: Access ajax data from the function and use it outside CI3 - SubrataJ - 04-23-2023 What do you mean by "access data from function edit_book", you want to use the response of this function outside, once the Ajax request is complete? RE: Access ajax data from the function and use it outside CI3 - InsiteFX - 04-23-2023 You need to use Code: jQuery.parseJSON( json ) RE: Access ajax data from the function and use it outside CI3 - SubrataJ - 04-23-2023 (04-23-2023, 10:30 PM)InsiteFX Wrote: You need to use pardon me for any mistakes, but he is using dataType: "JSON", is it really required to parse the data again? RE: Access ajax data from the function and use it outside CI3 - demyr - 04-24-2023 Hi. You can get results from your get_row controller method and display the result in another view file. For example, Code: Controller: Then you can use it after any Ajax call. For example, Code: <script type="text/javascript"> You can add another js/ajax in that towns-result view and also anything else. Hope this was the thing you need. RE: Access ajax data from the function and use it outside CI3 - janeiro - 04-24-2023 (04-23-2023, 09:07 PM)SubrataJ Wrote: What do you mean by "access data from function edit_book", you want to use the response of this function outside, once the Ajax request is complete? Yes, that's what I want to do |