This is a JavaScript to Ruby connection, that can pass data (JavaScript Object → Ruby Hash) to Ruby from your webpage. But it can also just cause the Ruby-side to send data by some means to your webpage or webserver.
The simplest way is to take data from a Ruby Hash object convert it to JSON using Ruby’s JSON library and pass it to the dialog via SketchUp API’s UI::HtmlDialog#execute_script method.
Ruby, at top of your extension submodule:
require "json"
Ruby, in your dialog setup method:
@dialog.add_action_callback('send_data') do |_unused, params|
# @data would be an instance variable to a Hash
data = @data.to_json
@dialog.execute_script( %[var data = JSON.parse('#{data}');] )
end
Now in your webpage you can use the data JS object.
But for more complex communication, you can use the SketchUp API’s Http::Request class to send the JSON data in the body of a request.
Likely you will set the "Content-Type"header to "application/json"