TomDuncan Active Member Licensed User Longtime User Jun 24, 2019 #1 Hi All, I have a websocket routine that I would like to send some json data to from my B4J. this is the html <script> side Code: Copy $(document).ready(function() { var data = #json#; var $lastEvent = $('#last_event_example_6'); var $lastEventContainer = $('#last_event_example_container_6'); var $flowchart = $('#example_6'); function drawimage(data) { $flowchart.flowchart('setData', data); } etc... and here is the ws code on a send button click. Code: Copy Sub loaddata_click (Params As Map) ' Log("clicked") Dim s As String = File.ReadString(File.DirApp,"json/temp.json") ws.RunFunction("drawimage",Array(s)) ws.Flush End Sub The loaddata button is working ok but nothing is being sent to flowchart. Any thoughts on what this novice is doing wrong. Tom
Hi All, I have a websocket routine that I would like to send some json data to from my B4J. this is the html <script> side Code: Copy $(document).ready(function() { var data = #json#; var $lastEvent = $('#last_event_example_6'); var $lastEventContainer = $('#last_event_example_container_6'); var $flowchart = $('#example_6'); function drawimage(data) { $flowchart.flowchart('setData', data); } etc... and here is the ws code on a send button click. Code: Copy Sub loaddata_click (Params As Map) ' Log("clicked") Dim s As String = File.ReadString(File.DirApp,"json/temp.json") ws.RunFunction("drawimage",Array(s)) ws.Flush End Sub The loaddata button is working ok but nothing is being sent to flowchart. Any thoughts on what this novice is doing wrong. Tom
Erel B4X founder Staff member Licensed User Longtime User Jun 24, 2019 #2 You are sending a string. You probably need to parse it with JSON.parse. Add some log messages in your JavaScript (console.log) and check them with the browser developer tools. Upvote 0
You are sending a string. You probably need to parse it with JSON.parse. Add some log messages in your JavaScript (console.log) and check them with the browser developer tools.