Many people on Domino forums ask about getting data from LotusScript agent without refreshing the page, as if it was a pure javascript function call. It is possible with AJAX, here is an example and a live demo.
This example sends text located in a DIV tag on a web page to a LotusScript agent and updates the DIV element with response data received back from the agent.
Live example
Sub Initialize
< script >
var http_request = false;
function makePOSTRequest(url, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = GetResponse;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function GetResponse() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
result = http_request.responseText;
document.getElementById('test').innerHTML = result;
} else {
alert('There was a problem with the request.');
}
}
}
function GetAgentData(txtdata) {
var poststr = txtdata; //encodeURI(txtdata);
makePOSTRequest('/test.nsf/postagent?openagent', poststr);
}
< /script >
-------------- LOTUSSCRIPT AGENT ---------------------
Sub Initialize
Dim session As New NotesSession
Dim doc As NotesDocument
Set doc=session.DocumentContext
req=doc.Request_Content(0)
For x=Len(req) To 1 Step -1
tmp=tmp+Mid(req,x,1)
Next
Print tmp
End Sub
Sunday, June 04, 2006
Subscribe to:
Post Comments (Atom)

4 comments:
welcome to the wow power leveling cheap wow power leveling service site, buy cheap wow gold,wotlk gold,world of warcraft power leveling buy wow gold
Weaknesses of World Of Warcraft Gold the client-server model used by World of Warcraft have been wow power levelingexploited in order to crash the cluster of servers that make up a realm. Exploits also include characters being able to instantly change location or teleport. The situation Cheap Wow Goldbecame worse when trying to coordinate activities across a number of players cheapest wow goldor guilds on the same realm.World of Warcraft Lead trade4gameProducer, stated that new realms would be introduced to relieve the burden on existing ones. Existing realms would be upgraded.
Although the game wow gold follows a similar model to others in the genreand was noted for having wow gold cheapmany familiar concepts from roleplaying games, the new approaches oggsaleto reduce pauses between game encounters was well liked. At various times, World of Warcraft players live4gamehave experienced problems with connecting to and logging in to wow gold for sale the game. Sudden server crashes that would force realms offline also occurred.
great post man :)
Great post. Has made the world of Ajax accessible to me using Lotus Notes.
Post a Comment