2012年3月8日 星期四

[Titanium] Pass JSON object to webview Javascript function

webview.evalJS('somefunction('+jsonObj+')');  <--- Not work, jsonObj is treated as string

The correct way is
webview.evalJS('somefunction('+JSON.stringify(jsonObj)+')');

The opposite of JSON.stringify() is JSON.parse()

沒有留言:

張貼留言