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.)
1 Answer 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.
-
I tried it, but still getting 404 error. (The url in console does not contain index anymore).user3748173– user37481732016年10月28日 19:45:30 +00:00Commented Oct 28, 2016 at 19:45
-
Also, the URL should not have 'checkout' in it.Aaron Allen– Aaron Allen2016年10月28日 20:19:07 +00:00Commented Oct 28, 2016 at 20:19
-
How can i remove it? Magento adds the 'checkout' to the URL. linkuser3748173– user37481732016年10月28日 21:08:24 +00:00Commented Oct 28, 2016 at 21:08
-
You put a slash at the start so that it is based off the root:
/controller/actioninstead ofcontroller/action.Aaron Allen– Aaron Allen2016年10月28日 22:52:51 +00:00Commented Oct 28, 2016 at 22:52
url: 'vendor_checkoutshipping/index/htmlcreator'in js file? Is that so?