Skip to content

How to wait till jsonrpc client returns response. #11

@gubkamatus

Description

@gubkamatus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions