Anybody get JSONRPC to work?


#1

Or any rpc for that matter?

This just causes the script to freeze and do nothing.

Script.include(‘http://foo.com/scripts/json2.js’);
Script.include(‘http://foo.com/scripts/jsonrpc.js’)

rpc = new JsonRPC(‘http://foo.com’,[‘get’],[‘post’]);


#2

Hello @Cracker_Hax ,

Not everything in those libraries is defined in the ScriptEngine of hifi. Assuming you used https://code.google.com/p/json-rpc/source/browse/trunk/jsonrpc-js/jsonrpc.js?r=49 . For example window.XMLHttpRequest doesn’t exist, because window isn’t defined, instead use XMLHttpRequest.

To fix these issues we need to modify the jsonrpc.js library, or perhaps we should consider implementing commonly used methods and variables to the ScriptEngine, like console.log() and window pointing to the ScriptEngine. Feel free to put a suggestion up in the worklist ( www.worklist.net ).

Greetings,

Thijs


#3

Is there currently any working http post across servers?


#4

Yes, simply use the JS native XMLHttpRequest.

See Tutorial How to use it


#5

As it turns out json already works. Here is a bit of code for anybody who needs it.

JsonRPC for HiFi