![]() |
How to differentiate ajax- and non-ajax-request? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: How to differentiate ajax- and non-ajax-request? (/showthread.php?tid=87004) |
How to differentiate ajax- and non-ajax-request? - hobbyci - 03-04-2023 Hello, I try to ajaxify my project and this works perfectly. The ajax onclick event works. But when I visit the url through my browser (e. g. visit my homepage via external website) of course no content will be displayed, because it is not an ajax request. I tried a couple of things but I can not manage it. File: application/core/My_Controller PHP Code: class MY_Controller extends CI_Controller In the destructor I echo-out my main-template. File: application/view/deskapp2/html/index Code: <html> This controller is for ajax calls. PHP Code: class Ajax extends CommonController { My plan here is of course to load all the stuff from a database depending on the uri. File: controller/welcome.php PHP Code: class Welcome extends FrontendController { ![]() I just play around. Summary: How can I differentiate between an ajax-request and a non-ajax-request? Any hints? ![]() Thanks to everyone who reads this. And like I said. I am not professional and I just play around to improve myself. RE: How to differentiate ajax- and non-ajax-request? - InsiteFX - 03-05-2023 CodeIgniter 4 Users Guide - General Topics - AJAX Requests CodeIgniter 3 has the same thing. |