I want to get the result from a JsonRPC call to a PHP server per JavaScript for further usage (drawing chart with Chart.js). For this I have a function which should do the call and return the result. I use this jQuery plugin: https://github.com/datagraph/jquery-jsonrpc
$.jsonRPC.setup({
endPoint: '/jsonserver.php'
});
var res; // first place
function getMyStuff() {
var res; // second place as alternative
$.jsonRPC.request('getResultsById', {
params: [1],
success: function(result) {
alert(JSON.stringify(result, null, 4)); // works well
res = result;
},
error: function(result) {
alert("error: " + JSON.stringify(result, null, 4));
}
});
return res;
}
My problem is that I don't know how to get the result out of the success block. If I call the function I always get undefined.