XINS - Ajax Example with the Dojo Toolkit
Description
This page is a demo that shows you how easy it is to use XINS in combination with the Ajax Dojo toolkit.
This example requires the myproject API to run on your computer.
To run the myproject API, go to the demo\xins-project directory and execute xins run-myproject.
For security reason, Firefox won't allow to call the API.
Form
A call is done to the API when you change the gender or lost the focus of the text field.
Answer:
Technical explanations
- I first created the myproject.smd file by executing xins -Dapi.name=myproject smd.
- The API is loaded as Javascript object using myproject = new dojo.rpc.JsonService("myproject.smd");.
- This object is used to call the function using JSON-RPC with var result = myproject.MyFunction(gender, name).
- The callback methods are defined using result.addCallbacks(applyResult, applyError);.
- And the result is displayed in the HTML with document.getElementById("answer").innerHTML = result.message;
You can have a look at the source code of this HTML page to fully understand this example.
Prev