I've implemented a small engine like the Rico ajaxEngine (please download the zip on the bottom of this file an open the index.html file in a browser).

The engine should work like the examples below. The engine.js file es commented.

Registering a service:

ajajEngine.registerService("Hello World", "/json/helloWorld");

Delcaring the processing function:

function myhello(result){
        alert(result.msg)
};

Registering the function into the engine:

ajajEngine.registerMethod("message", myhello);

Calling the service:

ajajEngine.callService("Hello Word")

So the events should happend like this:

  • The engine find the service on it's registry and call a loadJSONDoc function with the respective parameter.
  • As a result of the service call, it recive a json of this kind:
    {
            "type":"message",
            "msg":"Hello World!"
    }
    
  • Based on the "type" value chooses the function to call, myhello in this case and pass it the resulting json to allow it to process it, in the example showing an messagebox.

The engine is capable to understan not only a mesage but a lis of messages and dispach each of them.

* TODO: a working html generator for fields defined in json message.

Attachments