Magento 2 create ajax request from out of magentoHow to set custom tax price during add to cart in Magento 2No 'Access-Control-Allow-Origin' header in jquery ajax in magento siteMagento 2 No ‘Access-Control-Allow-Origin’ header is present on the requested resourceAjax call failed to load content from Controller in Magento 2.1.4 Enterprise Editionoauth/token/request not getting parameter from thirdparty applicationMagento 2 rest API - How to Manage API Authentication Lifecycle on Mobile Devices Application?401 Unauthorized for accessing customer apiUnable to get access_token for Magento2.0HTTP 401 Basic Authorization error accessing Magento 2 Rest APIResponse to preflight request doesn't pass access control checkMagento 2 NO Access-Control-Allow-Origin redirect on other web site

Adobe Illustrator: How can I change the profile of a dashed stroke?

Is there any mention of ghosts who live outside the Hogwarts castle?

Can someone get a spouse off a deed that never lived together and was incarcerated?

Is there a solution to paying high fees when opening and closing lightning channels once we hit a fee only market?

Caught with my phone during an exam

Negative impact of having the launch pad away from the Equator

Way of refund if scammed?

Find this Unique UVC Palindrome ( ignoring signs and decimal) from Given Fractional Relationship

How to test if argument is a single space?

Is ideal gas incompressible?

Does attacking (or having a rider attack) cancel Charge/Pounce-like abilities?

Wifi light switch needs neutral wire. Why? AND Can that wire be a skinny one?

How to become an Editorial board member?

Salesforce bug enabled "Modify All"

Congruence, Equal, and Equivalence

Is being an extrovert a necessary condition to be a manager?

How to make Flex Markers appear in Logic Pro X?

Download app bundles from App Store to run on iOS Emulator on Mac

mmap: effect of other processes writing to a file previously mapped read-only

amsmath: How can I use the equation numbering and label manually and anywhere?

What pc resources are used when bruteforcing?

Managing heat dissipation in a magic wand

What is the winged creature on the back of the Mordenkainen's Tome of Foes book?

Is the default 512 byte physical sector size appropriate for SSD disks under Linux?



Magento 2 create ajax request from out of magento


How to set custom tax price during add to cart in Magento 2No 'Access-Control-Allow-Origin' header in jquery ajax in magento siteMagento 2 No ‘Access-Control-Allow-Origin’ header is present on the requested resourceAjax call failed to load content from Controller in Magento 2.1.4 Enterprise Editionoauth/token/request not getting parameter from thirdparty applicationMagento 2 rest API - How to Manage API Authentication Lifecycle on Mobile Devices Application?401 Unauthorized for accessing customer apiUnable to get access_token for Magento2.0HTTP 401 Basic Authorization error accessing Magento 2 Rest APIResponse to preflight request doesn't pass access control checkMagento 2 NO Access-Control-Allow-Origin redirect on other web site






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








3















I wanna create Ajax request from empty HTML with jQuery.
I do like this



$.ajax(
url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
type: "POST",
success: function (d)
alert(d);

);


but always I get error



Access to XMLHttpRequest at 'http://localhost:8000/rest/V1/integration/admin/token?username=magento&password=magento2' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 


I know I should add some header before send request but jquery does not support headers.
Anyone gets this error?










share|improve this question






























    3















    I wanna create Ajax request from empty HTML with jQuery.
    I do like this



    $.ajax(
    url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
    type: "POST",
    success: function (d)
    alert(d);

    );


    but always I get error



    Access to XMLHttpRequest at 'http://localhost:8000/rest/V1/integration/admin/token?username=magento&password=magento2' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 


    I know I should add some header before send request but jquery does not support headers.
    Anyone gets this error?










    share|improve this question


























      3












      3








      3


      1






      I wanna create Ajax request from empty HTML with jQuery.
      I do like this



      $.ajax(
      url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
      type: "POST",
      success: function (d)
      alert(d);

      );


      but always I get error



      Access to XMLHttpRequest at 'http://localhost:8000/rest/V1/integration/admin/token?username=magento&password=magento2' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 


      I know I should add some header before send request but jquery does not support headers.
      Anyone gets this error?










      share|improve this question
















      I wanna create Ajax request from empty HTML with jQuery.
      I do like this



      $.ajax(
      url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
      type: "POST",
      success: function (d)
      alert(d);

      );


      but always I get error



      Access to XMLHttpRequest at 'http://localhost:8000/rest/V1/integration/admin/token?username=magento&password=magento2' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. 


      I know I should add some header before send request but jquery does not support headers.
      Anyone gets this error?







      magento2 ajax security






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 16 at 8:44









      magefms

      3,0973631




      3,0973631










      asked May 15 at 6:38









      gh darvishanigh darvishani

      360217




      360217




















          1 Answer
          1






          active

          oldest

          votes


















          0














          You can try this and check, use method instead of type:



          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
          method: "POST",
          success: function (d)
          alert(d);

          );


          Or with headers using jquery and prototype



          require([
          'jquery',
          'prototype'
          ], function($)
          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token",
          method: "POST",
          "headers":
          "username": "magento",
          "password": "magento2"
          ,
          success: function (d)
          alert(d);

          );
          );





          share|improve this answer

























          • hi @magefms, can you look into this issue and help me please,magento.stackexchange.com/questions/274520/…

            – jafar pinjar
            May 15 at 6:54











          • @jafarpinjar let me check

            – magefms
            May 15 at 7:02











          • Thank you @magefrms

            – jafar pinjar
            May 15 at 7:03











          • hi @magefms, is it possible to set tax amount from controller, am i using correctly?

            – jafar pinjar
            May 15 at 7:30












          • sorry ...it does not worked

            – gh darvishani
            May 16 at 20:10











          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%2f274631%2fmagento-2-create-ajax-request-from-out-of-magento%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can try this and check, use method instead of type:



          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
          method: "POST",
          success: function (d)
          alert(d);

          );


          Or with headers using jquery and prototype



          require([
          'jquery',
          'prototype'
          ], function($)
          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token",
          method: "POST",
          "headers":
          "username": "magento",
          "password": "magento2"
          ,
          success: function (d)
          alert(d);

          );
          );





          share|improve this answer

























          • hi @magefms, can you look into this issue and help me please,magento.stackexchange.com/questions/274520/…

            – jafar pinjar
            May 15 at 6:54











          • @jafarpinjar let me check

            – magefms
            May 15 at 7:02











          • Thank you @magefrms

            – jafar pinjar
            May 15 at 7:03











          • hi @magefms, is it possible to set tax amount from controller, am i using correctly?

            – jafar pinjar
            May 15 at 7:30












          • sorry ...it does not worked

            – gh darvishani
            May 16 at 20:10















          0














          You can try this and check, use method instead of type:



          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
          method: "POST",
          success: function (d)
          alert(d);

          );


          Or with headers using jquery and prototype



          require([
          'jquery',
          'prototype'
          ], function($)
          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token",
          method: "POST",
          "headers":
          "username": "magento",
          "password": "magento2"
          ,
          success: function (d)
          alert(d);

          );
          );





          share|improve this answer

























          • hi @magefms, can you look into this issue and help me please,magento.stackexchange.com/questions/274520/…

            – jafar pinjar
            May 15 at 6:54











          • @jafarpinjar let me check

            – magefms
            May 15 at 7:02











          • Thank you @magefrms

            – jafar pinjar
            May 15 at 7:03











          • hi @magefms, is it possible to set tax amount from controller, am i using correctly?

            – jafar pinjar
            May 15 at 7:30












          • sorry ...it does not worked

            – gh darvishani
            May 16 at 20:10













          0












          0








          0







          You can try this and check, use method instead of type:



          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
          method: "POST",
          success: function (d)
          alert(d);

          );


          Or with headers using jquery and prototype



          require([
          'jquery',
          'prototype'
          ], function($)
          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token",
          method: "POST",
          "headers":
          "username": "magento",
          "password": "magento2"
          ,
          success: function (d)
          alert(d);

          );
          );





          share|improve this answer















          You can try this and check, use method instead of type:



          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token?username=***&password=****",
          method: "POST",
          success: function (d)
          alert(d);

          );


          Or with headers using jquery and prototype



          require([
          'jquery',
          'prototype'
          ], function($)
          $.ajax(
          url: "http://****.com/rest/V1/integration/admin/token",
          method: "POST",
          "headers":
          "username": "magento",
          "password": "magento2"
          ,
          success: function (d)
          alert(d);

          );
          );






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 15 at 7:02

























          answered May 15 at 6:51









          magefmsmagefms

          3,0973631




          3,0973631












          • hi @magefms, can you look into this issue and help me please,magento.stackexchange.com/questions/274520/…

            – jafar pinjar
            May 15 at 6:54











          • @jafarpinjar let me check

            – magefms
            May 15 at 7:02











          • Thank you @magefrms

            – jafar pinjar
            May 15 at 7:03











          • hi @magefms, is it possible to set tax amount from controller, am i using correctly?

            – jafar pinjar
            May 15 at 7:30












          • sorry ...it does not worked

            – gh darvishani
            May 16 at 20:10

















          • hi @magefms, can you look into this issue and help me please,magento.stackexchange.com/questions/274520/…

            – jafar pinjar
            May 15 at 6:54











          • @jafarpinjar let me check

            – magefms
            May 15 at 7:02











          • Thank you @magefrms

            – jafar pinjar
            May 15 at 7:03











          • hi @magefms, is it possible to set tax amount from controller, am i using correctly?

            – jafar pinjar
            May 15 at 7:30












          • sorry ...it does not worked

            – gh darvishani
            May 16 at 20:10
















          hi @magefms, can you look into this issue and help me please,magento.stackexchange.com/questions/274520/…

          – jafar pinjar
          May 15 at 6:54





          hi @magefms, can you look into this issue and help me please,magento.stackexchange.com/questions/274520/…

          – jafar pinjar
          May 15 at 6:54













          @jafarpinjar let me check

          – magefms
          May 15 at 7:02





          @jafarpinjar let me check

          – magefms
          May 15 at 7:02













          Thank you @magefrms

          – jafar pinjar
          May 15 at 7:03





          Thank you @magefrms

          – jafar pinjar
          May 15 at 7:03













          hi @magefms, is it possible to set tax amount from controller, am i using correctly?

          – jafar pinjar
          May 15 at 7:30






          hi @magefms, is it possible to set tax amount from controller, am i using correctly?

          – jafar pinjar
          May 15 at 7:30














          sorry ...it does not worked

          – gh darvishani
          May 16 at 20:10





          sorry ...it does not worked

          – gh darvishani
          May 16 at 20:10

















          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%2f274631%2fmagento-2-create-ajax-request-from-out-of-magento%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

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?