javascript - How to make an JsonP request using ajax-core + Polymer -


i'm starting webcomponents , trying use polymer , ajax-core ajax request. need make request api, don't know how handle cors problem.

my code looks like.

<link rel="import" href="../polymer/polymer.html"> <link rel="import" href="../core-ajax/core-ajax.html">  <polymer-element name="test-form"> <template>  <textarea></textarea> <button on-click="{{buttonclick}}">load</button>  <core-ajax id="ajaxsubmit" url="someexternalapi" method="get" response="{{response}}">   </core-ajax> </template>  <script> polymer("contact-form",{     buttonclick:function(){         this.$.ajaxsubmit.go();     },     responsechanged:function(oldvalue){         console.log(this.response);     } }); </script>  </polymer-element> 

but way of i'm getting no 'access-control-allow-origin' error.

any ideas?

thank you!

there 2 ways:

  1. if can have control on backend can enable cors
  2. or can use polymer-jsonp (see here example)

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -