1 Reply Latest reply on Aug 17, 2015 3:05 AM by EugenF.

    run script after variable has value (XML ajax request)

    EugenF.

      I would like to use XML data to set values in text elements. When I try to get information from the variable at this point, I get empty values. But it works well when I use the variable later in the code, as examle in the mouseover event.

       

      Code in .compositionReady:

       

      var xmlData;

       

      $.ajax({

        url: 'content.xml',

        dataType: 'xml',

        success: function(data){

        xmlData = $('element',data);

        sym.getComposition().getStage().$("txt_titel").html(xmlData.find("00").find("text").text( )); //<-------- delivers an empty value

        },

        error: function(data){

        alert("Error loading Map Content from XML");

        }

      });

       

      Could someboday help me, please? What should be changed to get the code work?

        • 1. Re: run script after variable has value (XML ajax request)
          EugenF. Level 1

          Got it:

           

          var xmlData;

           

          $.ajax({

            url: 'content.xml',

            dataType: 'xml',

            success: function(data){

            xmlData = $('element',data);

            sym.initText();

            },

            error: function(data){

            alert("Error loading Map Content from XML");

            }

          });

           

          sym.initText = function(){

               sym.getComposition().getStage().$("txt_titel").html(xmlData.find("00").find("text").text( ));

          };

           

          Thanks anyway.