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 is the motivation for a law requiring 2 parties to consent for recording a conversation
Old scifi movie from the 50s or 60s with men in solid red uniforms who interrogate a spy from the past
Why is the maximum length of OpenWrt’s root password 8 characters?
Can there be female White Walkers?
Is it okay to consider publishing in my first year of PhD?
Why doesn't shell automatically fix "useless use of cat"?
Are there any other methods to apply to solving simultaneous equations?
Can an undergraduate be advised by a professor who is very far away?
Can withdrawing asylum be illegal?
Why can't devices on different VLANs, but on the same subnet, communicate?
Dropping list elements from nested list after evaluation
Why doesn't UInt have a toDouble()?
How to type this arrow in math mode?
How to add class in ko template in magento2
Short story: man watches girlfriend's spaceship entering a 'black hole' (?) forever
Is there a way to generate a uniformly distributed point on a sphere from a fixed amount of random real numbers?
What information about me do stores get via my credit card?
Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?
How to charge AirPods to keep battery healthy?
Loose spokes after only a few rides
Output the Arecibo Message
Getting crown tickets for Statue of Liberty
Why are there uneven bright areas in this photo of black hole?
Match Roman Numerals
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
10 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 18 mins ago
Bhakti ThakkarBhakti Thakkar
584114
584114
you better useMagentoFrameworkAppRequestHttp
– magefms
10 mins ago
add a comment |
you better useMagentoFrameworkAppRequestHttp
– magefms
10 mins ago
you better use
MagentoFrameworkAppRequestHttp
– magefms
10 mins ago
you better use
MagentoFrameworkAppRequestHttp
– magefms
10 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 5 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 1 min 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
10 mins ago