Ajax success is not working in codeigniter - 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: Ajax success is not working in codeigniter (/showthread.php?tid=74455) |
Ajax success is not working in codeigniter - AKKU - 09-25-2019 I need to pass some values from my controller to view. Here is my controller. Code: public function my_function() Whenever I add the [b]include APPPATH .'class/MyClass.php';[/b] to my controller, the echo is not working, but when I remove that the echo is working and gives me an alert with "1" in my view. Here is my ajax in view Code: $.ajax({ RE: Ajax success is not working in codeigniter - ciadmin - 09-25-2019 What does MyClass have to do with anything? and why would you try to "include" it? It sounds like my_function() is a method inside your Home controller, in which case the AJAX reference would work. Better would be to use "site_url('home/my_function');", as that will add the index.php if needed. RE: Ajax success is not working in codeigniter - AKKU - 09-25-2019 include APPPATH . 'class/MyClass.php'; $networkOnlineArray['Field_Existence_Indicator_Transaction']['amount']=$amount; $networkOnlineArray['Field_Existence_Indicator_Billing']['billToFirstName']=$name; $networkOnlineObject=new MyClass($networkOnlineArray); $requestParameter = $networkOnlineObject->NeoPostData; Actually I need to pass "$requestParameter" to the view. So that I can't avoide the that function RE: Ajax success is not working in codeigniter - ciadmin - 09-25-2019 Hmm - that's not the CI4 way! You should have to "include" anything! It looks like you are mixing traditional PHP with CI4 RE: Ajax success is not working in codeigniter - AKKU - 09-25-2019 So what should I do, How can I access the class anyway. I am new to CI. RE: Ajax success is not working in codeigniter - ciadmin - 09-25-2019 Can't tell wihtout knowing more about your app, and I don't have time for that now, sorry. I trust you hace gone through the CI4 tutorial and introduciton sections in the user guide? They try to explain how to use CI4. RE: Ajax success is not working in codeigniter - demyr - 09-26-2019 I still use CI 3 not 4 yet, however let me give you a working example of Ajax which might help you. The example below is about "updating some informations of a company" AJAX : Code: <script type="text/javascript"> Controller : PHP Code: public function function_name_please(){ |