kendo101 Posted February 18, 2015 Share Posted February 18, 2015 Hello, I am trying to understand the structure for a module. Currently I have my module installed and displaying on the front end as expected and I am trying to AJAX the module to return information. My module files looks like: mydomain.com/modules/mymodule/mymodule.php (basic install, uninstall, hook) mydomain.com/modules/mymodule/view/template/hook/mymodule.tpl (displays some js and a button) mydomain.com/modules/mymodule/controller/front/ajax-call.php (echos a test string) My javascript is: <script type="text/javascript"> function testfunc(){ $.ajax({ url: '{$base_dir}modules/mymodule/ajax-call.php', type: 'get', data: 'ajax=true', success: function(data) { console.log('success'); // OTHER SUCCESS COMMAND - CHECK THE RETURN VALUE } }); return false; } $(document).ready(function(){ $("#testbtn").click(function(){ testfunc(); }); }); </script> But it runs into a 404 response when the button is clicked. I've also tried moving the ajax-call.php into the root of the module as the path would suggest but that also returns 404 so I am not sure why it is not hitting the page. Can anyone help? Link to comment Share on other sites More sharing options...
fred-vinapresta Posted February 18, 2015 Share Posted February 18, 2015 Hi, you shoud change {$base_dir}modules/mymodule/ajax-call.php by {$base_dir}modules/mymodule/controller/front/ajax-call.php in the url parameter Link to comment Share on other sites More sharing options...
kendo101 Posted February 18, 2015 Author Share Posted February 18, 2015 I have already tried that, I cannot reach anything with my module folder: GET http://www.mydomain.info/modules/mymodule/controller/front/ajax-call.php?ajax=true/ 404 (Not Found) <- file DOES exist at that path GET http://www.mydomain.info/modules/mymodule/ajax-call.php?ajax=true/ 404 (Not Found) <- file DOES exist at that path My route to modules in Preferences -> SEO is the default: module/{module}{/:controller} Link to comment Share on other sites More sharing options...
Vinum Posted February 19, 2015 Share Posted February 19, 2015 Hi, In which file you added your script ? If it is in the php file, {$base_dir} is not good. If it is in tpl, verify {$base_dir} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now