Your main problem is that the AJAX call is asynchronous, but you expect the data to be there synchronously. IOW, you are trying to use `filteredDataset` before the AJAX data is back from the network.
As it happens, you can also reduce your project code dramatically by taking advantage of several polymer features. Here is a reduced version: http://jsbin.com/vekes/4/edit Notice that JQuery is no longer necessary. I made a lot of changes, please follow up with any questions. On Mon, Apr 14, 2014 at 12:43 PM, Riccardo M. <[email protected]> wrote: > Hi Scott, I'm the author of the question on Stack Overflow :) I've just > published a lighter version of the original code (it doesn't work anyway, > now even if I make the same ajax call it doesn't work): > http://jsbin.com/vexeq/7/edit?html,output > > After execution, you'll find this in console.log: > Uncaught TypeError: Cannot read property 'photos' of null > > I don't think it is a parseJSON error, because in the original > implementation I use the same method to parse other json string and it > works. > > Thank you for your support! :) > > Il giorno lunedì 14 aprile 2014 18:25:13 UTC+2, Scott Miles ha scritto: >> >> Fyi: http://stackoverflow.com/questions/23063667/troubles- >> with-multiple-ajax-requests-from-different-instances-of-a-custom-elemen >> >> >> On Mon, Apr 14, 2014 at 8:42 AM, Eric Bidelman <[email protected]> wrote: >> >>> Can you provide a jsbin of what you're trying to do? It's hard to debug >>> code without code :) >>> >>> >>> On Mon, Apr 14, 2014 at 8:04 AM, Riccardo M. <[email protected]> wrote: >>> >>>> Hi there, >>>> I've got the following scenario: >>>> >>>> - I created two Polymer Elements, let's call them respectively >>>> "interpreter" and "viewer" >>>> >>>> - Basically, the "interpreter" makes an AJAX request to get data with >>>> jQuery $.ajax(). When the request is completed, the interpreter processes >>>> the answer, and provides it to the "viewer". >>>> >>>> - When the interpreter finishes to process the data, the "viewer" is >>>> registered (just once) and instantiated into the "interpreter" (it is >>>> appended to a div inside the "interpreter" template). The "viewer" gets the >>>> data from the "interpreter" as attribute directly in the declaration tag >>>> (like this: <polymer-viewer data="{json object}></polymer-viewer>). >>>> >>>> When I declare just one instance of the "interpreter" I've got no >>>> problem to display correctly the "viewer". >>>> Same result when I declare more than one instance of the "interpreter" >>>> with the same URL in the AJAX request. >>>> >>>> I noticed that when I declare more than one instance of the >>>> "interpreter" (hence, when I want to display more than one "viewer") with >>>> different URLs in the AJAX request, only the first "interpreter" that >>>> receives a response from the AJAX request is able to render correctly the >>>> "viewer" (i.e. when the second instance gets the results, the results set >>>> is null, although in the declaration tag I can see the attribute with the >>>> dataset from the "interpreter"). >>>> >>>> It seems a synchronization problem between the AJAX request and the >>>> instantiation/rendering task. >>>> In fact, serializing the AJAX requests (setting async = false) both the >>>> "viewer" can be rendered. >>>> >>>> Any suggestions? >>>> >>>> Thank you :) >>>> >>>> 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/b8ebe1ab-c92c-4131-a073-343133b91e7e% >>>> 40googlegroups.com<https://groups.google.com/d/msgid/polymer-dev/b8ebe1ab-c92c-4131-a073-343133b91e7e%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> 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/CACGqRCAghrCU6iDcpDcf%3D510-PkC9G-HF-knu1T3pambVGkUiA% >>> 40mail.gmail.com<https://groups.google.com/d/msgid/polymer-dev/CACGqRCAghrCU6iDcpDcf%3D510-PkC9G-HF-knu1T3pambVGkUiA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> 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/d7e66a48-ad7c-4b85-8c10-4ca941429f3f%40googlegroups.com<https://groups.google.com/d/msgid/polymer-dev/d7e66a48-ad7c-4b85-8c10-4ca941429f3f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > 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/CAHbmOLYRoySK7K3WVVO3s4hZ5neOVuqGUQa7i6znyo1gB7CC-g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
