javascriptiostitaniumtitanium-sdk

"DataCloneError: The object can not be cloned." in titanium 8.0.0


DataCloneError: The object can not be cloned." getting this while using SDK 8.0.0 for below code. any idea why am getting this ? this error i am not getting in SDK less than 8.0.0

Titanium is fireEvent to another ExtJs Javascript Code base inside same project but outside Titanium folder. That ExtJS is calling API and getting responses. This response is again sending back to Titanium. Then Titanium is serving that responses. Reference code tracing see screenshot i attached in third message.

window.Ti.App.fireEvent('SampleApp', {data: message});

enter image description here


Solution

  • Looks like you're trying to send an object from one JS context to another. Because objects are being sent as a reference and not the raw data itself, you would want to send the raw data instead.

    So, use fireEvent('SampleApp', {data: JSON.stringify(message)})

    Inside the receiving end, you want to use JSON.parse(payload.data) to get the data out again.