Hi. I created a webpage with a 12 month calendar in it. Each date has an unique “id” that I can reference via javascript. I am currently trying to use XMLHTTP requests to pull in data from a view that’s associated with a specific date on the calendar. (I must use XMLHTTP to accomplish this task…)
For example, when I mouseover the 5th of May on the calendar, I want a popup box to show the details related to that day from the view (could be info from one or more documents). I have the code for the popup box, I just don’t know how to use the XMLHTTP requests to make such queries into the view and then return the data.
Any working examples out there??
Thanks!
Subject: RE: XMLHTTP Request
Stan, the link you posted doesn’t give any examples of XMLHTTPRequest…
Subject: RE: XMLHTTP Request
Yes it does – download the database.
Subject: RE: XMLHTTP Request
Yes, you are correct Stan. I apologize… I already saw the same example from O’reilly’s xml site… I am still not sure how the actual data is found and returned from a Notes view - not a document with embedded XML… are there additional examples??
Subject: RE: XMLHTTP Request
Hi,The code below is a sample to send an xmlHTTP Request and view the results. Paste the code in ‘onLoad’ event of the form and change the url as per your need.
var Url = “http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb?readviewentries”
xmlHttpObj = new ActiveXObject(“Microsoft.XMLHTTP”);
xmlHttpObj.open(“GET”, Url, true);
xmlHttpObj.onreadystatechange = function() {
if (xmlHttpObj.readyState == 4) {
if (xmlHttpObj.status == 200) {
var response = xmlHttpObj.responseXML.documentElement;
var oNode =xmlHttpObj.responseXML.getElementsByTagName('viewentry')[0];
if(oNode != null) {
for ( var c=oNode.firstChild; oNode!=null; oNode=oNode.nextSibling ) {
alert(c.nodeName);
alert(c.text);
}
}
}
}
}
xmlHttpObj.send(null);
Hope this helps.
Praba
Subject: RE: XMLHTTP Request
That’s absolutely lovely – if you want your application to be IE-only, and only on Windows. The code linked to is cross-browser, and supports recent versions of Mozilla (Netscape, Firefox), Safari/Konqueror and Opera on just about any platform that can run a browser. If you are using this code now, you should seriously consider incorporating the browser-native XMLHttpRequest object in order to open your application to a wider world.
Subject: RE: XMLHTTP Request
Here is the code for cross-browser Mozilla (firefox) and IE.
var Url = “http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb?readviewentries&count=5”
if (window.XMLHttpRequest) {
var xmlHttpObj = new XMLHttpRequest();
xmlHttpObj.open(“GET”, Url, true);
}
else if (window.ActiveXObject) {
var xmlHttpObj = new ActiveXObject(“Microsoft.XMLHTTP”);
if (xmlHttpObj) {
xmlHttpObj.open("GET", Url, true);
}
}
xmlHttpObj.onreadystatechange = function() {
if (xmlHttpObj.readyState == 4) {
if (xmlHttpObj.status == 200) {
.........
.........
The above code is compatiable withe Mozilla and IE but not sure about cross platform.
Thanks
Praba
Subject: RE: XMLHTTP Request
Which, as I said, was linked to above. Why be redundant?
Subject: RE: XMLHTTP Request
Thanks Praba… I’m currently doing something similar, but I also check for the browser type… I will post my solution back at this forum later on. Thanks again Praba and thanks Stan for your feedback as well…
Subject: RE: XMLHTTP Request
There is a great write-up on LDD about how iNotes tackled this issue. There are 3 ways to handle XML GETs in modern browsers:
-
XML data islands in IE.
-
Leveraging the Microsoft XMLHTTP ActiveXObject
-
Use the XMLHttpRequest object
To get a true cross-browser solution you’ll usually need to combine multiple methods, as #1 is IE-specific, #2 relies on ActiveX being allowed from an OS and security standpoint, and #3 doesn’t work on IE.
I just finished some serious work on this (essentially recreating the Java View Applet through XML and DHTML), and was able to build a solution that works great in virtually any modern web browser: IE 5.0+, NS 6.1+, and Firefox 0.93+.
Subject: RE: XMLHTTP Request
Also check out the Designer help. In particular the specification for the “” and “” element.
Subject: RE: XMLHTTP Request
Use ?ReadViewEntries (instead of ?OpenView) to get XML data directly from a view. You can use RestrictToCategory, Start, Count, StartKey and so forth to determine what set of documents will be returned. Take a look at the resulting XML in your browser (manual entry, no code) – it’ll tell you which nodes are of interest to you.
Subject: RE: XMLHTTP Request
… and you’ll probably want to check out Jack Ratcliff’s site as well:
http://www.jackratcliff.com/