On 20/08/2015 10:02, Anandhi Subramani wrote: > Hi am trying to rean an external json file as response to an ajax > call. But am not able to display the value from json in template using > binding. Am using polymer 1.0 >From your code it's probably dying before assigning the variable because you've got incorrect javascript syntax in your Polymer() call, which is likely causing all javascript to stop running. > <template> > <iron-ajax > auto > url:"http://localhost:3000/input.json", > method:'GET', > dataType: "json", > last-response="{{ajaxResponse}}"> You're assigning the value of the response to a variable named identically to a function that already exists. The resultant behaviour as far as I can tell is undefined, but will probably overwrite the function (effectively deleting the function from memory). To use ajaxResponse as a function you need to change the above to rename or remove the assigned variable and add an on-ajax-response="ajaxResponse" attribute. Don't forget to alter the textarea definition for the updated variable name below. > </iron-ajax> > <textarea value="{{ajaxResponse.degree}}"></textarea> > </template> > > <script> > Polymer({ > is: 'gauge-ajax' The next two characters are incorrect for Polymer 1.0, which only has one argument to the Polymer function, > }, so, remove the curly bracket but leave the comma (you can move the comma onto the end of the is: line if it looks more neat). > ajaxResponse: function(request) { > console.log(request.detail.response); > console.log(this.$.ajax.lastResponse); > } You now need to close the function request and object argument with "});" without the quotes. > </script>
Follow Polymer on Google+: plus.google.com/107187849809354688692 --- You received this message because you are subscribed to the Google Groups "Polymer" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/55D5FAF5.6080901%40bowlhat.net. For more options, visit https://groups.google.com/d/optout.
