Skip to main content
added 5 characters in body
Source Link
Diana
  • 5.3k
  • 1
  • 11
  • 26

as discussed, i see that a few corrections are needed:

  1. you should call the 'test_testmodule/index/test' url as you defined your frontName as 'test_testmodule'
  2. you should use the 'standard' routerId if you are working on the frontend side with this call
  3. you are expecting a JSON formatted response as per your AJAX call definition, so you will have to format it serverside by injecting Magento\Framework\Controller\Result\JsonFactory into a protected property (say $resultJsonFactory) inside your controller class and using it like so:
$result = $this->resultJsonFactory->create();
return $result->setData(['success' => true]);

as discussed, i see a few corrections are needed:

  1. you should call the 'test_testmodule/index/test' url as you defined your frontName as 'test_testmodule'
  2. you should use the 'standard' routerId if you are working on the frontend side with this call
  3. you are expecting a JSON formatted response as per your AJAX call definition, so you will have to format it serverside by injecting Magento\Framework\Controller\Result\JsonFactory into a protected property (say $resultJsonFactory) inside your controller class and using it like so:
$result = $this->resultJsonFactory->create();
return $result->setData(['success' => true]);

as discussed, i see that a few corrections are needed:

  1. you should call the 'test_testmodule/index/test' url as you defined your frontName as 'test_testmodule'
  2. you should use the 'standard' routerId if you are working on the frontend side with this call
  3. you are expecting a JSON formatted response as per your AJAX call definition, so you will have to format it serverside by injecting Magento\Framework\Controller\Result\JsonFactory into a protected property (say $resultJsonFactory) inside your controller class and using it like so:
$result = $this->resultJsonFactory->create();
return $result->setData(['success' => true]);
Source Link
Diana
  • 5.3k
  • 1
  • 11
  • 26

as discussed, i see a few corrections are needed:

  1. you should call the 'test_testmodule/index/test' url as you defined your frontName as 'test_testmodule'
  2. you should use the 'standard' routerId if you are working on the frontend side with this call
  3. you are expecting a JSON formatted response as per your AJAX call definition, so you will have to format it serverside by injecting Magento\Framework\Controller\Result\JsonFactory into a protected property (say $resultJsonFactory) inside your controller class and using it like so:
$result = $this->resultJsonFactory->create();
return $result->setData(['success' => true]);