• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. Creating a User Interface > Passing Complex Values in Remote Calls

Passing Complex Values in Remote Calls

To exchange simple values such as strings and numbers between Bridge and an HTML UI page, you can simply pass arguments and return values of those types in your callback and execJS functions. However, complex values such as objects and arrays must be broken down and reconstructed on the other side. This is true for communication in both directions—callbacks from HTML to Bridge, and execution of HTML script functions by Bridge using execJs.

For a callback to receive an object as an argument, the calling function on the HTML side must serialize the object into a string, using toSource, and pass the serialized string. On the Bridge side, the callback function uses eval to reconstruct the object from the serialized string. Similarly, to pass an object back, the callback function must use toSource to serialize the object and return the serialized string. The receiving code on the HTML side must in turn reconstruct the object using eval. See the example below.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint