main.js
:
var data = {
foo: "bar",
val: $('#text-to-send').val()
}
$('#set-text').on('click', function() {
var $this = $(this);
JSONRPCClient.call('set-text',
data,
function(result) {
console.log(result);
},
function(error) {
addError(error);
});
});
I have also tried with true JSON:
var data = {
"foo": "bar",
"val": $('#text-to-send').val()
}
ofApp.cpp
:
void ofApp::setText(JSONRPC::MethodArgs& args)
{
// Set the user text.
userText = args.params.asString();
cout<<userText<<endl;
}
Error:
[ error ] ServerWebSocketRouteHandler::handleRequest: exception: Type is not convertible to string