Module-documentation

version 1.0.0
module: itsa-io
maintanance: Marco Asbreuk
home
all modules

Streamed IO.readXML()

Get streamed XML-object from the server using ITSA.IO.readXML() using streamback.

Click on the button to initiate the request.

Code-example:

<body>
    <div id="container">
        <button id="button-get">Click me get data</button>
    </div>
    <div id="target-container"></div>
</body>
<script src="itsabuild-min.js"></script>
<script>
    var url = 'http://servercors.itsa.io/example/stream',
        container = document.getElementById('target-container'),
        writeResponse, writeResponse, streamFn;

    readyResponse = function(xml) {
        // `xml` has all the complete xml-object, but we don't use it here.
        container.append('<br>READY');
    };

    errorResponse = function(e) {
        container.setText(e.message);
    };

    streamFn = function(xml) {
        // xml should be an xml-object
        container.append(xml.documentElement.children);
    };

    ITSA.Event.after(
        'tap',
        function() {
            container.innerHTML = '';
            ITSA.IO.readXML(url, {example: 2}, {streamback: streamFn}).then(readyResponse, errorResponse);
        },
        '#button-get'
    );
</script>
API Docs