core ajax into polymer element dont do the response function -


dont response handler function, dont know why

outside paper elemet, using document.getelemetbyid(), respnser, when put paper element, dont anything.

here code:

<link rel="import" href="bower_components/polymer/polymer.html"> <link rel="import" href="bower_components/core-ajax/core-ajax.html"> <polymer-element name="post-service" attributes="posts"> <template>     <style>         :host {             display: none;         }     </style>      <core-ajax auto url="http://yami-no-seire.hol.es/blog/api/get_recent_posts/" on-core-response="{{postsloaded}}" handleas="json">     </core-ajax> </template> <script>     polymer({         created: function () {             this.posts = [];         },          /*ajax success callback method*/         postsloaded: function() {         console.log("ok");              var respuesta = this.$.ajax              /*document.queryselector('#student-table-template').model = {                 posts: e.detail.response             };*/             var data = respuesta.detail.response.posts,                 posts = [],                 el = document.createelement("div");             // build custom object             (var = 0; < data.length; i++) {                 //escape title                 el.innerhtml = data[i].title;                 var title = el.innerhtml;                 //escape content                 el.innerhtml = data[i].excerpt;                 var excerpt = el.innerhtml;                  entradas.push({                     url: data[i].url,                     title: title,                     excerpt: excerpt.replace('&nbsp;', ' ').replace('<p>', '').replace('</p>', ''),                     modified: parsedate(data[i].modified),                     name: data[i].author.name                 });             }             this.posts = posts;         }     });      function parsedate(date) {                 var d = new date(date);                 var months = ["january", "february", "march",   "april", "may", "june", "july", "august", "september",   "october", "november", "december" ];                 return d.getdate() + " - " + months[d.getmonth()] + " - " + d.getfullyear();             }; </script> </polymer-element> 

it looks core-ajax dont handler request.

automatic node finding

this.$.ajax 

targets elements id attribute, missing in core-ajax element:

<core-ajax auto url="(my url)" id='ajax'... 

here working example: plunk

edit: here how catch response inside postsloaded:

 postsloaded: function(e, detail, sender){      console.log('postsloaded');     console.log(e.detail.response);   }, 

but if not getting 'ok' log, can wrong url.


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -