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

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

If my opponent casts Ultimate Price on my Phantasmal Bear, can I save it by casting Snap or Curfew?

How to type this arrow in math mode?

How to support a colleague who finds meetings extremely tiring?

What is preventing me from simply constructing a hash that's lower than the current target?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

How do you keep chess fun when your opponent constantly beats you?

How do I free up internal storage if I don't have any apps downloaded?

Falsification in Math vs Science

Getting crown tickets for Statue of Liberty

If climate change impact can be observed in nature, has that had any effect on rural, i.e. farming community, perception of the scientific consensus?

Dropping list elements from nested list after evaluation

Loose spokes after only a few rides

How to charge AirPods to keep battery healthy?

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

What information about me do stores get via my credit card?

Why does the nucleus not repel itself?

What do I do when my TA workload is more than expected?

Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?

Pokemon Turn Based battle (Python)

How to translate "being like"?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?



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;








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.










share|improve this question






















  • you better use MagentoFrameworkAppRequestHttp

    – magefms
    2 mins ago

















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.










share|improve this question






















  • you better use MagentoFrameworkAppRequestHttp

    – magefms
    2 mins ago













0












0








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.










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 10 mins ago









Bhakti ThakkarBhakti Thakkar

574114




574114












  • you better use MagentoFrameworkAppRequestHttp

    – magefms
    2 mins ago

















  • you better use MagentoFrameworkAppRequestHttp

    – magefms
    2 mins ago
















you better use MagentoFrameworkAppRequestHttp

– magefms
2 mins ago





you better use MagentoFrameworkAppRequestHttp

– magefms
2 mins ago










0






active

oldest

votes












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
);



);













draft saved

draft discarded


















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

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Nidaros erkebispedøme

Birsay

Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?