Tuesday, January 18, 2011

short dojo + ajax example how to get data from db

There are 3 most useful ahax-approaches I use when working with Lotus Domino:
- getting view as JSON. database.nsf/viewname?readviewentries& OutputFormat=JSON (fast and modern)

- agent approach (example here, most flexible and probably most slow approach)
- page/form/view as elelemnts, f.x. database.nsf/myform?openform&unid=123123 (easy to use but not  flexible, I use it very rarely)

Very small and known example of dojo's ajax, I'm getting some information from agent and then will use it in my JS later.

var jsondata;
dojo.xhrGet({
url: "database/agentGetData?Openagent&param1=id1",
sync: true,
load: function(data) {
jsondata = data;
}
});

I'm interesting in any another 'smart' approaches, so if u have some interesting idea we can discuss in comments them.

6 comments :

Thomas Adrian said...

nice, when you work with xPages your Ajax request is as simple as a "partial refresh" checkbox.

Dmytro said...

right, but xPage is still not everywhere, so we need to know how to do that in classic lotus web development.

Mark Hughes said...

Also this is helpfull when you are writing an html5 app and want to get info from the server while all the elements reside cached in the browser

Unknown said...
This comment has been removed by the author.
Unknown said...

I see this is CSJS. Is there a way to do this with SSJS - as opposed to the Agent.Run? I need to send query string parameters to the agent - not save a document to pass to it.

Unknown said...

Ted Ryan you can pass parameters to the agent?