Magento 2 - Unable to Get Request Params in controller The 2019 Stack Overflow Developer Survey Results Are InRemove or manipulate parameters in controllerAdding request params to observer redirectOverwriting controller vs overwriting action controller requestMagento 2.1: Invoke urlBuilder->getUrl() in a controller in a custom moduleCan't get my ajax request to call controllerMagento 2 - Send processed data from Controller to PHTMLMagento 2 - Send form data to Controller using AJAX and return Result to PHTMLHow to send parameter to controllerGetting raw request body in controllercall a controller in other module
How to charge AirPods to keep battery healthy?
How can I add encounters in the Lost Mine of Phandelver campaign without giving PCs too much XP?
Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?
Pokemon Turn Based battle (Python)
How to quickly solve partial fractions equation?
How do you keep chess fun when your opponent constantly beats you?
How to type a long/em dash `—`
Ubuntu Server install with full GUI
Worn-tile Scrabble
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
writing variables above the numbers in tikz picture
How to add class in ko template in magento2
What is the meaning of Triage in Cybersec world?
How to type this arrow in math mode?
What is the most efficient way to store a numeric range?
What does Linus Torvalds mean when he says that Git "never ever" tracks a file?
What do I do when my TA workload is more than expected?
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?
Are there any other methods to apply to solving simultaneous equations?
A word that means fill it to the required quantity
What do these terms in Caesar's Gallic Wars mean?
"as much details as you can remember"
What is preventing me from simply constructing a hash that's lower than the current target?
Magento 2 - Unable to Get Request Params in controller
The 2019 Stack Overflow Developer Survey Results Are InRemove or manipulate parameters in controllerAdding request params to observer redirectOverwriting controller vs overwriting action controller requestMagento 2.1: Invoke urlBuilder->getUrl() in a controller in a custom moduleCan't get my ajax request to call controllerMagento 2 - Send processed data from Controller to PHTMLMagento 2 - Send form data to Controller using AJAX and return Result to PHTMLHow to send parameter to controllerGetting raw request body in controllercall a controller in other module
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to get input data in the controller but controller not getting url params.
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
/**
* @var MagentoFrameworkViewResultPageFactory
*/
protected $resultPageFactory;
protected $resultJsonFactory;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
JsonFactory $resultJsonFactory
)
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
return parent::__construct($context);
public function execute()
var_dump($this->getRequest()->getParams());die("testing");
//echo '<pre>';
//print_r($this->getRequest('height')->getParams());exit;
$height = $this->getRequest()->getParam('height');
//$height = 5;
$weight = $this->getRequest()->getParam('weight');
$result = $this->resultJsonFactory->create();
$resultPage = $this->resultPageFactory->create();
$block = $resultPage->getLayout()
->createBlock('CrudCrudatfrontendBlockIndex')
->setTemplate('Crud_Crudatfrontend::result.phtml')
->setData('height',$height)
->setData('weight',$weight)
->toHtml();
$result->setData($block);
return $result;
Here is my phtml file
<div class="row clearfix">
<div class="col-md-12 column">
<form name="form_height" method="POST" id="form_height">
<input type="text" name="height" class="form-control input-md">
<input type="text" name="weight" class="form-control input-md">
<input type="submit" id="calculateTotalSubmit" name="calculate-total-submit" value="Calculate Total">
</div>
</form>
</div>
</div>
<script>
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery("#form_height").submit(function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
</script>
I am getting values in console.
controllers magento-2.1.7 parameter
add a comment |
I am trying to get input data in the controller but controller not getting url params.
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
/**
* @var MagentoFrameworkViewResultPageFactory
*/
protected $resultPageFactory;
protected $resultJsonFactory;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
JsonFactory $resultJsonFactory
)
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
return parent::__construct($context);
public function execute()
var_dump($this->getRequest()->getParams());die("testing");
//echo '<pre>';
//print_r($this->getRequest('height')->getParams());exit;
$height = $this->getRequest()->getParam('height');
//$height = 5;
$weight = $this->getRequest()->getParam('weight');
$result = $this->resultJsonFactory->create();
$resultPage = $this->resultPageFactory->create();
$block = $resultPage->getLayout()
->createBlock('CrudCrudatfrontendBlockIndex')
->setTemplate('Crud_Crudatfrontend::result.phtml')
->setData('height',$height)
->setData('weight',$weight)
->toHtml();
$result->setData($block);
return $result;
Here is my phtml file
<div class="row clearfix">
<div class="col-md-12 column">
<form name="form_height" method="POST" id="form_height">
<input type="text" name="height" class="form-control input-md">
<input type="text" name="weight" class="form-control input-md">
<input type="submit" id="calculateTotalSubmit" name="calculate-total-submit" value="Calculate Total">
</div>
</form>
</div>
</div>
<script>
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery("#form_height").submit(function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
</script>
I am getting values in console.
controllers magento-2.1.7 parameter
you better useMagentoFrameworkAppRequestHttp
– magefms
11 mins ago
add a comment |
I am trying to get input data in the controller but controller not getting url params.
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
/**
* @var MagentoFrameworkViewResultPageFactory
*/
protected $resultPageFactory;
protected $resultJsonFactory;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
JsonFactory $resultJsonFactory
)
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
return parent::__construct($context);
public function execute()
var_dump($this->getRequest()->getParams());die("testing");
//echo '<pre>';
//print_r($this->getRequest('height')->getParams());exit;
$height = $this->getRequest()->getParam('height');
//$height = 5;
$weight = $this->getRequest()->getParam('weight');
$result = $this->resultJsonFactory->create();
$resultPage = $this->resultPageFactory->create();
$block = $resultPage->getLayout()
->createBlock('CrudCrudatfrontendBlockIndex')
->setTemplate('Crud_Crudatfrontend::result.phtml')
->setData('height',$height)
->setData('weight',$weight)
->toHtml();
$result->setData($block);
return $result;
Here is my phtml file
<div class="row clearfix">
<div class="col-md-12 column">
<form name="form_height" method="POST" id="form_height">
<input type="text" name="height" class="form-control input-md">
<input type="text" name="weight" class="form-control input-md">
<input type="submit" id="calculateTotalSubmit" name="calculate-total-submit" value="Calculate Total">
</div>
</form>
</div>
</div>
<script>
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery("#form_height").submit(function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
</script>
I am getting values in console.
controllers magento-2.1.7 parameter
I am trying to get input data in the controller but controller not getting url params.
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
/**
* @var MagentoFrameworkViewResultPageFactory
*/
protected $resultPageFactory;
protected $resultJsonFactory;
/**
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory,
JsonFactory $resultJsonFactory
)
$this->resultPageFactory = $resultPageFactory;
$this->resultJsonFactory = $resultJsonFactory;
return parent::__construct($context);
public function execute()
var_dump($this->getRequest()->getParams());die("testing");
//echo '<pre>';
//print_r($this->getRequest('height')->getParams());exit;
$height = $this->getRequest()->getParam('height');
//$height = 5;
$weight = $this->getRequest()->getParam('weight');
$result = $this->resultJsonFactory->create();
$resultPage = $this->resultPageFactory->create();
$block = $resultPage->getLayout()
->createBlock('CrudCrudatfrontendBlockIndex')
->setTemplate('Crud_Crudatfrontend::result.phtml')
->setData('height',$height)
->setData('weight',$weight)
->toHtml();
$result->setData($block);
return $result;
Here is my phtml file
<div class="row clearfix">
<div class="col-md-12 column">
<form name="form_height" method="POST" id="form_height">
<input type="text" name="height" class="form-control input-md">
<input type="text" name="weight" class="form-control input-md">
<input type="submit" id="calculateTotalSubmit" name="calculate-total-submit" value="Calculate Total">
</div>
</form>
</div>
</div>
<script>
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery("#form_height").submit(function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
</script>
I am getting values in console.
controllers magento-2.1.7 parameter
controllers magento-2.1.7 parameter
asked 19 mins ago
Bhakti ThakkarBhakti Thakkar
584114
584114
you better useMagentoFrameworkAppRequestHttp
– magefms
11 mins ago
add a comment |
you better useMagentoFrameworkAppRequestHttp
– magefms
11 mins ago
you better use
MagentoFrameworkAppRequestHttp
– magefms
11 mins ago
you better use
MagentoFrameworkAppRequestHttp
– magefms
11 mins ago
add a comment |
2 Answers
2
active
oldest
votes
Try this using MagentoFrameworkAppRequestHttp
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
MagentoFrameworkControllerResultJson
add a comment |
Try this,
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery('#calculateTotalSubmit').on('click', function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
and your form post action should be like action="#"
Hope this helps
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269810%2fmagento-2-unable-to-get-request-params-in-controller%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try this using MagentoFrameworkAppRequestHttp
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
MagentoFrameworkControllerResultJson
add a comment |
Try this using MagentoFrameworkAppRequestHttp
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
MagentoFrameworkControllerResultJson
add a comment |
Try this using MagentoFrameworkAppRequestHttp
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
MagentoFrameworkControllerResultJson
Try this using MagentoFrameworkAppRequestHttp
<?php
namespace CrudCrudatfrontendControllerResult;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkViewResultPageFactory;
use MagentoFrameworkControllerResultJsonFactory;
class Result extends MagentoFrameworkAppActionAction
MagentoFrameworkControllerResultJson
answered 6 mins ago
magefmsmagefms
2,6352528
2,6352528
add a comment |
add a comment |
Try this,
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery('#calculateTotalSubmit').on('click', function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
and your form post action should be like action="#"
Hope this helps
add a comment |
Try this,
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery('#calculateTotalSubmit').on('click', function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
and your form post action should be like action="#"
Hope this helps
add a comment |
Try this,
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery('#calculateTotalSubmit').on('click', function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
and your form post action should be like action="#"
Hope this helps
Try this,
require(['jquery'],function()
jQuery(document).ready(function()
alert("hi")
jQuery('#calculateTotalSubmit').on('click', function()
var heightValue = jQuery("input[name='height']").val();
var weightValue = jQuery("input[name='weight']").val();
var url = "<?php echo $block->getBaseUrl().'crud/result/result/' ?>";
jQuery.ajax(
url: url,
type: "POST",
data: height:heightValue,weight:weightValue,
//data: jQuery(this).serialize(),
success: function(response)
// alert(heightValue);
console.log(response.output);
window.location.href = url;
);
return false;
);
);
);
and your form post action should be like action="#"
Hope this helps
answered 2 mins ago
Prathap GunasekaranPrathap Gunasekaran
1,7831618
1,7831618
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269810%2fmagento-2-unable-to-get-request-params-in-controller%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you better use
MagentoFrameworkAppRequestHttp
– magefms
11 mins ago