1

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 https://127.0.0.1:8443/checkout/vendor_checkoutshipping/index/htmlcreator 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.)

2
  • 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. Commented Oct 28, 2016 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? Commented Oct 28, 2016 at 13:30

1 Answer 1

1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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