I want to make Ajax request to the controller from checkout page. The code I have in github and in my previous post were I did not specify that I want to make the ajax request from js file placed on checkout page. The current ajax request is displaying an error in console: jquery.js:9666 POST 404 (Not Found). Does anyone have any idea what might be wrong that the ajax request is not made?

I prefer not to use phtml file, unless I really need to (the reason for using would possible security threth). (My module currently does not need phtml file.)

  • Do you have a route defined for your controller? The URL that you have for the Ajax call suggests that you are missing that piece of the puzzle. – Aaron Allen Oct 28 '16 at 1:13
  • I can not understand what you mean by "having route defined for your controller"? You can see yourself what files i have in github. I suspect that the problem is that i can't use jQuery url: 'vendor_checkoutshipping/index/htmlcreator' in js file? Is that so? – user3748173 Oct 28 '16 at 13:30

The ajax request url should not have 'index' in it. The url should be vendor_checkoutshipping/htmlcreator. Placing a controller in the Controller/Index folder and/or naming it Index.php means that the word 'index' is not included in the url path.

  • I tried it, but still getting 404 error. (The url in console does not contain index anymore). – user3748173 Oct 28 '16 at 19:45
  • Also, the URL should not have 'checkout' in it. – Aaron Allen Oct 28 '16 at 20:19
  • How can i remove it? Magento adds the 'checkout' to the URL. link – user3748173 Oct 28 '16 at 21:08
  • You put a slash at the start so that it is based off the root: /controller/action instead of controller/action. – Aaron Allen Oct 28 '16 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.