json-rpc2php icon indicating copy to clipboard operation
json-rpc2php copied to clipboard

How to wait till jsonrpc client returns response.

Open gubkamatus opened this issue 11 years ago • 0 comments

I have JS client: In JS I have function: ----------------------Start code------------------- var codebook_onlinedb;

function getCodeBook() { jsonrpcclient = new jsonrpcphp('http://some.url/server.php', function() { jsonrpcclient.cCodeBook.getCodeBook("inout", function(jsonRpcObj) { codebook_onlinedb = $.map(jsonRpcObj.result, function(value, index) { return [value]; }); }); });

function doSomething() { console.log( 'main: ' + codebook_onlinedb); }

var x = getCodeBook(); doSomething();

End of code

In firebug console: http://oi61.tinypic.com/2u7m1r9.jpg In firebug console I have two POST calls. First gives me a list of methods and second gives me correct response to my task but my JS function doSomething is performed in first POST. Why? Or how can I wait to correct response from second POST. Thanks.

gubkamatus avatar Sep 05 '14 20:09 gubkamatus