Sending ajax POST data to controllersending information from one controller to anotherTrying to run an AJAX script from the admin area in magentoHow to send a form key with post data using ajax to a controller in magento?jQuery ajax data to controllerMagento ajax form does not post dataCall an external URL and post data to it (same as an HTML form does) from a controllerAJAX login, how to pass data response from controller to jQuery with AjaxMagento 2.2.4 : post data in urlMagento 2 AJAX Post to another module's controller

Does the damage from the Absorb Elements spell apply to your next attack, or to your first attack on your next turn?

How do I reattach a shelf to the wall when it ripped out of the wall?

All ASCII characters with a given bit count

Can someone publish a story that happened to you?

Philosophical question on logistic regression: why isn't the optimal threshold value trained?

Combinatorics problem, right solution?

Older movie/show about humans on derelict alien warship which refuels by passing through a star

Why did Rep. Omar conclude her criticism of US troops with the phrase "NotTodaySatan"?

Von Neumann Extractor - Which bit is retained?

How can I wire a 9-position switch so that each position turns on one more LED than the one before?

A Paper Record is What I Hamper

Multiple fireplaces in an apartment building?

Multiple options vs single option UI

As an international instructor, should I openly talk about my accent?

Can a level 2 Warlock take one level in rogue, then continue advancing as a warlock?

What is this word supposed to be?

What makes accurate emulation of old systems a difficult task?

How to pronounce 'c++' in Spanish

Co-worker works way more than he should

Is there metaphorical meaning of "aus der Haft entlassen"?

How to not starve gigantic beasts

Extracting Dirichlet series coefficients

Is there any pythonic way to find average of specific tuple elements in array?

Find a stone which is not the lightest one



Sending ajax POST data to controller


sending information from one controller to anotherTrying to run an AJAX script from the admin area in magentoHow to send a form key with post data using ajax to a controller in magento?jQuery ajax data to controllerMagento ajax form does not post dataCall an external URL and post data to it (same as an HTML form does) from a controllerAJAX login, how to pass data response from controller to jQuery with AjaxMagento 2.2.4 : post data in urlMagento 2 AJAX Post to another module's controller






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















This is my ajax request:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
$(".emailfocusout").focusout(function()
$.ajax(
url: '/checkout/Email/Email',
type: 'POST',
data: 'email': 'che607@yahoo.com',
contentType: 'application/json',
success: function(data)
console.log('SUCCESS: ', data);
,
error: function(data)
console.log('ERROR: ', data);
,
);
);
);
</script>


This is my controller:



public function EmailAction()

// TODO: Implement me! Here are some hints ;-)

$email = $this->getRequest()->getParam('email');
var_dump($email);
echo $email;



I can't save - data: 'email': 'che607@yahoo.com' - to - $email = $this->getRequest()->getParam('email');



What am I doing wrong?



* UPDATE - SOLVED *
I took data out of the ajax request. And in URL I put:



url: '/checkout/Email/Email/email/me@example.com',


I worked like that.










share|improve this question
























  • can you please upload your model file or database install script?

    – Rohan Hapani
    Aug 5 '18 at 16:24











  • Do you getting data in controller?

    – Prashant Valanda
    Aug 5 '18 at 18:35

















0















This is my ajax request:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
$(".emailfocusout").focusout(function()
$.ajax(
url: '/checkout/Email/Email',
type: 'POST',
data: 'email': 'che607@yahoo.com',
contentType: 'application/json',
success: function(data)
console.log('SUCCESS: ', data);
,
error: function(data)
console.log('ERROR: ', data);
,
);
);
);
</script>


This is my controller:



public function EmailAction()

// TODO: Implement me! Here are some hints ;-)

$email = $this->getRequest()->getParam('email');
var_dump($email);
echo $email;



I can't save - data: 'email': 'che607@yahoo.com' - to - $email = $this->getRequest()->getParam('email');



What am I doing wrong?



* UPDATE - SOLVED *
I took data out of the ajax request. And in URL I put:



url: '/checkout/Email/Email/email/me@example.com',


I worked like that.










share|improve this question
























  • can you please upload your model file or database install script?

    – Rohan Hapani
    Aug 5 '18 at 16:24











  • Do you getting data in controller?

    – Prashant Valanda
    Aug 5 '18 at 18:35













0












0








0








This is my ajax request:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
$(".emailfocusout").focusout(function()
$.ajax(
url: '/checkout/Email/Email',
type: 'POST',
data: 'email': 'che607@yahoo.com',
contentType: 'application/json',
success: function(data)
console.log('SUCCESS: ', data);
,
error: function(data)
console.log('ERROR: ', data);
,
);
);
);
</script>


This is my controller:



public function EmailAction()

// TODO: Implement me! Here are some hints ;-)

$email = $this->getRequest()->getParam('email');
var_dump($email);
echo $email;



I can't save - data: 'email': 'che607@yahoo.com' - to - $email = $this->getRequest()->getParam('email');



What am I doing wrong?



* UPDATE - SOLVED *
I took data out of the ajax request. And in URL I put:



url: '/checkout/Email/Email/email/me@example.com',


I worked like that.










share|improve this question
















This is my ajax request:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
$(".emailfocusout").focusout(function()
$.ajax(
url: '/checkout/Email/Email',
type: 'POST',
data: 'email': 'che607@yahoo.com',
contentType: 'application/json',
success: function(data)
console.log('SUCCESS: ', data);
,
error: function(data)
console.log('ERROR: ', data);
,
);
);
);
</script>


This is my controller:



public function EmailAction()

// TODO: Implement me! Here are some hints ;-)

$email = $this->getRequest()->getParam('email');
var_dump($email);
echo $email;



I can't save - data: 'email': 'che607@yahoo.com' - to - $email = $this->getRequest()->getParam('email');



What am I doing wrong?



* UPDATE - SOLVED *
I took data out of the ajax request. And in URL I put:



url: '/checkout/Email/Email/email/me@example.com',


I worked like that.







controllers ajax post-data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 15:12









Abhishek Panchal

3,6203929




3,6203929










asked Aug 5 '18 at 16:16









Che FigueroaChe Figueroa

112




112












  • can you please upload your model file or database install script?

    – Rohan Hapani
    Aug 5 '18 at 16:24











  • Do you getting data in controller?

    – Prashant Valanda
    Aug 5 '18 at 18:35

















  • can you please upload your model file or database install script?

    – Rohan Hapani
    Aug 5 '18 at 16:24











  • Do you getting data in controller?

    – Prashant Valanda
    Aug 5 '18 at 18:35
















can you please upload your model file or database install script?

– Rohan Hapani
Aug 5 '18 at 16:24





can you please upload your model file or database install script?

– Rohan Hapani
Aug 5 '18 at 16:24













Do you getting data in controller?

– Prashant Valanda
Aug 5 '18 at 18:35





Do you getting data in controller?

– Prashant Valanda
Aug 5 '18 at 18:35










2 Answers
2






active

oldest

votes


















0














just use only



data: 'email=me@example.com',


and if you want to send dynamic email value use



data:'email='+$("input[name='email']").val(),





share|improve this answer
































    0














    Change this,



     $.ajax(
    url: '/checkout/Email/Email',
    type: 'POST',
    data: 'email': 'che607@yahoo.com',
    contentType: 'application/json',
    success: function(data)
    console.log('SUCCESS: ', data);
    ,
    error: function(data)
    console.log('ERROR: ', data);
    ,
    );


    to



     $.ajax(
    type: 'POST',
    url: '/checkout/Email/Email',
    data: 'email': 'che607@yahoo.com',
    dataType: 'json',
    success: function(data)
    console.log('SUCCESS: ', data);
    ,
    error: function(data)
    console.log('ERROR: ', data);
    ,
    );





    share|improve this answer























      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%2f237216%2fsending-ajax-post-data-to-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









      0














      just use only



      data: 'email=me@example.com',


      and if you want to send dynamic email value use



      data:'email='+$("input[name='email']").val(),





      share|improve this answer





























        0














        just use only



        data: 'email=me@example.com',


        and if you want to send dynamic email value use



        data:'email='+$("input[name='email']").val(),





        share|improve this answer



























          0












          0








          0







          just use only



          data: 'email=me@example.com',


          and if you want to send dynamic email value use



          data:'email='+$("input[name='email']").val(),





          share|improve this answer















          just use only



          data: 'email=me@example.com',


          and if you want to send dynamic email value use



          data:'email='+$("input[name='email']").val(),






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 5 '18 at 20:04









          Marius

          168k28324694




          168k28324694










          answered Aug 5 '18 at 16:27









          Ansar HusainAnsar Husain

          1,773218




          1,773218























              0














              Change this,



               $.ajax(
              url: '/checkout/Email/Email',
              type: 'POST',
              data: 'email': 'che607@yahoo.com',
              contentType: 'application/json',
              success: function(data)
              console.log('SUCCESS: ', data);
              ,
              error: function(data)
              console.log('ERROR: ', data);
              ,
              );


              to



               $.ajax(
              type: 'POST',
              url: '/checkout/Email/Email',
              data: 'email': 'che607@yahoo.com',
              dataType: 'json',
              success: function(data)
              console.log('SUCCESS: ', data);
              ,
              error: function(data)
              console.log('ERROR: ', data);
              ,
              );





              share|improve this answer



























                0














                Change this,



                 $.ajax(
                url: '/checkout/Email/Email',
                type: 'POST',
                data: 'email': 'che607@yahoo.com',
                contentType: 'application/json',
                success: function(data)
                console.log('SUCCESS: ', data);
                ,
                error: function(data)
                console.log('ERROR: ', data);
                ,
                );


                to



                 $.ajax(
                type: 'POST',
                url: '/checkout/Email/Email',
                data: 'email': 'che607@yahoo.com',
                dataType: 'json',
                success: function(data)
                console.log('SUCCESS: ', data);
                ,
                error: function(data)
                console.log('ERROR: ', data);
                ,
                );





                share|improve this answer

























                  0












                  0








                  0







                  Change this,



                   $.ajax(
                  url: '/checkout/Email/Email',
                  type: 'POST',
                  data: 'email': 'che607@yahoo.com',
                  contentType: 'application/json',
                  success: function(data)
                  console.log('SUCCESS: ', data);
                  ,
                  error: function(data)
                  console.log('ERROR: ', data);
                  ,
                  );


                  to



                   $.ajax(
                  type: 'POST',
                  url: '/checkout/Email/Email',
                  data: 'email': 'che607@yahoo.com',
                  dataType: 'json',
                  success: function(data)
                  console.log('SUCCESS: ', data);
                  ,
                  error: function(data)
                  console.log('ERROR: ', data);
                  ,
                  );





                  share|improve this answer













                  Change this,



                   $.ajax(
                  url: '/checkout/Email/Email',
                  type: 'POST',
                  data: 'email': 'che607@yahoo.com',
                  contentType: 'application/json',
                  success: function(data)
                  console.log('SUCCESS: ', data);
                  ,
                  error: function(data)
                  console.log('ERROR: ', data);
                  ,
                  );


                  to



                   $.ajax(
                  type: 'POST',
                  url: '/checkout/Email/Email',
                  data: 'email': 'che607@yahoo.com',
                  dataType: 'json',
                  success: function(data)
                  console.log('SUCCESS: ', data);
                  ,
                  error: function(data)
                  console.log('ERROR: ', data);
                  ,
                  );






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 6 '18 at 7:20









                  Anjali PatilAnjali Patil

                  64




                  64



























                      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%2f237216%2fsending-ajax-post-data-to-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

                      Sum ergo cogito? 1 nng

                      419 nièngy_Soadمي 19bal1.5o_g

                      Queiggey Chernihivv 9NnOo i Zw X QqKk LpB