passing data to javascript from xml files

  • Hi there I'm experimenting with linking tours together and want to be able to control/effect/change data within a javascript file from an xml file.

    For example I have two tours one which links to a panorama in the other and vice versa I have managed to do this one way through javascript to the xml file but can't figure out the reverse route through javascript prob just tired and not thinking straight
    *confused* *sleeping* *squint* *sleeping* *sleeping*

  • Hi Klaus:

    Using code similar to the below, I can't seem to get information from a <data/> element passed to a Javascript function. Is this not possible currently?

    Code
    //JAVASCRIPT:
    var myText = krpano().call("get(data[myData].content);");
    document.getElementById("somediv").innerHTML = "<span><strong>" + myText + "</strong></span>";
    
    
    <!-- XML: -->
    <data name="myData">
    	<p>Hello<br />World</p>
    </data>

    Thanks in advance,

    Patrick

    QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

  • OK, so the call may not return data.
    Big deal, almost assuredly, krpano can run javascript too.
    JS -> Run krpano function, do variable stuff, run JS function to update the DOM.

    Easy peazy.

    JS function to run krpano function -> Krpano function to run JS function->

    Hi Sacha:

    I don't quite understand what you mean... Are you saying there's a way to get the data element's text into a Javascript function (from krpano xml --> javascript in the page)? That's what I'm trying to do... and it comes up as nothing, empty, or fails without error.

    Or are you saying I can just run the Javascript from right within the XML? Or... ?

    Thanks,

    Patrick

    QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

  • Exactly, you can grab the data element with krpano and use it, and you should be able to call a js function in krpano with those contents or at least, I don't see why not?

    Well, me neither. Thus my original post *wink*

    To wit:

    Using code similar to the below, I can't seem to get information from a <data/> element passed to a Javascript function. Is this not possible currently?

    Code
    //JAVASCRIPT:
    var myText = krpano().call("get(data[myData].content);");
    document.getElementById("somediv").innerHTML = "<span><strong>" + myText + "</strong></span>";
    
    
    <!-- XML: -->
    <data name="myData">
    	<p>Hello<br />World</p>
    </data>

    Thanks in advance,

    Patrick

    QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

  • Do you have a working test Sacha? Love to see it! I've been trying various methods for a while (see other posts in the forum here). I can successfully call this and other JS from krpano; jsut can't get info from krpano xml into the javascript.

    QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

    Einmal editiert, zuletzt von patrickcheatham (1. April 2011 um 02:36)

  • Hi Klaus:

    Using code similar to the below, I can't seem to get information from a <data/> element passed to a Javascript function. Is this not possible currently?

    Code
    //JAVASCRIPT:
    var myText = krpano().call("get(data[myData].content);");
    document.getElementById("somediv").innerHTML = "<span><strong>" + myText + "</strong></span>";
    
    
    <!-- XML: -->
    <data name="myData">
    	<p>Hello<br />World</p>
    </data>

    Sigh.

    OK, below is the working implementation (both ways, from Javascript to KRPano or the reverse):

    Code
    //Javascript:
    var myText;
    myText = krpano().get("data[someData].content");
    
    
    <!-- XML: -->
    <!-- call javascript function "someFunction(arg1, arg2, arg3, [arg...])"-->
    js( someFunction(get(data[someData].content), BlahBlah, Another Line of Blah) ) ;

    Thanks for putting up with my whinery *g*

    HTH,

    Patrick

    QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

  • You bastard, and I just finished my example. ;)

    http://www.seeit360.net/jstest/


    This passes a variable into krpano, increments it, and passes it back out ..

    Hopefully, I learned something here as well.

    Sigh.

    OK, below is the working implementation (both ways, from Javascript to KRPano or the reverse):

    Code
    //Javascript:
    var myText;
    myText = krpano().get("data[someData].content");
    
    
    
    
    
    
    js( someFunction(get(data[someData].content), BlahBlah, Another Line of Blah) ) ;

    Thanks for putting up with my whinery *g*

    HTH,

    Patrick

  • *smile*

    Well, you one-upped me with an actual example. *wink* Good work!

    WHEW.

    Cheers,

    Patrick

    ps: as was succinctly put to me, off-list, this morning:
    "call() does not have a returnvalue, get() does."

    QTVR • AS3 • 360° Photography • Art Gallery • Storefront • Books • Generative Art • ?

    Einmal editiert, zuletzt von patrickcheatham (1. April 2011 um 18:03)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!