15 Replies Latest reply on Jul 21, 2014 10:13 AM by HHJsyndrome

    Trying to use getJSON with onClick function but get uncaught TypeError

    HHJsyndrome

      Uncaught TypeError: Cannot read property '$' of undefined


      Hi, I'm trying to use getJSON function when a button is clicked. however I get the above error. However if I use the code under compositionReady, everything works fine.


      But I want my app to work in such a way that when I click the button the function gets the information on the json file and displays the information dynamically. What is the correct solution to implement this function. I am thinking that I can use this function inside the compositionReady function and just hide the information and display it when the button is clicked. But is there any other way or approach which I can take?


      $.getJSON("content.JSON")

        .success(

        function(data){

        console.log("incoming data: ", data);

       

       

        $.each(data, function(index, item){

        var l = sym.createChildSymbol( "template", "content");

        l.$("item").html( item.item );

        l.$("description").html( item.description );

        l.play(index * -500);

        });

        });