Select Page
Callbacks Documentation
Edit on
Codepen.io

data-data-callback

A JavaScript function you should provide, which will be invoked when new JSON (“order object”) is obtained from the server. This function must accept 1 parameter, an object. See more information on returned data structure in Accessing the Library from Javascript.


x
33
 
1
<!--
2
    Configure an add button to add an item to the cart.
3
-->
4
<button onclick="fastspring.builder.add('phot-io-main-app');">Add to cart to update the returned data</button>
5
6
<!--
7
    DEMO EFFECTS
8
        - The below div will be updated to include the returned data from the data-data-callback
9
-->
10
<br /><br />Data returned: <div id="log"></div>
11
12
<!--
13
    DEMO SETUP
14
        - Initialize the Store Builder Library
15
-->
16
<script
17
    id="fsc-api"
18
    src="https://sbl.onfastspring.com/sbl/1.0.2/fastspring-builder.min.js"
19
    type="text/javascript"
20
    data-storefront="fastspringexamples.test.onfastspring.com/popup-fastspringexamples"
21
    data-data-callback="dataCallback"
22
    data-continuous="true">
23
</script>
24
25
<!--
26
    dataCallback function
27
        - In this example, it will updated the div with the id of log with the returned data.
28
-->
29
<script>
30
    function dataCallback(data) {
31
        document.getElementById("log").innerHTML = "<pre>"+JSON.stringify(data, null, 4)+"</pre>";
32
    }
33
</script>
1
 
1
1
 
1

Related Topics