Monday, September 7, 2009

Ajax function in lotus domino to display a html view in a div innerHTML

The below function is developed in ajax. Paste the following code in the JSHeader of the form.

Create a div with the ID as "Mainbody" to place a web view.

Onload call the processAjax() function.


function processAjax() {

url=dbPath + "Viewname?openview"
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = targetDiv;
try {
req.open("GET", url, true);
} catch (e) {
alert("Problem : " + e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = targetDiv;
req.open("GET", url, true);
req.send();

}
}
}

function targetDiv() {
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
var oldchild = document.getElementById("child");
if(oldchild!=null)
{
//document.forms.getElementById("Mainbody").removeChild(oldchild);
document.getElementById("Mainbody").removeChild(oldchild);
}
//-------------------------------------------------------------------
//Create a new div
var wrappingElement = document.createElement('div');
wrappingElement.setAttribute('id',"child");
//Insert response text into new div
wrappingElement.innerHTML = req.responseText;
if(req.responseText.indexOf("No documents found") > 0){
wrappingElement.innerHTML="

Your Message Hear";
//attendee.appendChild(wrappingElement12);
}
//Append new div into mainbody
Mainbody.appendChild(wrappingElement);
setTimeout('processAjax()',10000);
} else {
// alert("Problem: " + req.statusText);
alert("Problem: Server Down1");
}

}
}

7 comments:

  1. hello,

    I hope I can help, I want in a new menu where options allow me to open a view, open them in a div on the same page, I do not want to use iframes or open in a new window

    ReplyDelete
  2. What's up every one, here every person is sharing these know-how, so it's fastidious to read
    this website, and I used to pay a visit this weblog every day.
    My homepage web design miami beach

    ReplyDelete
  3. Hey there! I'm at work browsing your blog from my new apple iphone! Just wanted to say I love reading through your blog and look forward to all your posts! Carry on the fantastic work!
    Also visit my homepage - cheap laptops for sale

    ReplyDelete
  4. Thanks for finally writing about > "Ajax function in lotus domino to display a html view in a div innerHTML" < Liked it!
    Also visit my website ; sci-fi book blog

    ReplyDelete
  5. An impressive share! I've just forwarded this onto a co-worker who had been doing a little research on this. And he actually bought me dinner due to the fact that I discovered it for him... lol. So allow me to reword this.... Thanks for the meal!! But yeah, thanx for spending time to discuss this issue here on your website.
    Also visit my webpage - Credit Repair Reviews

    ReplyDelete
  6. Appreciate the recommendation. Let me try it out.
    My homepage ; how do you get acid reflux

    ReplyDelete
  7. There's definately a great deal to learn about this issue. I really like all the points you have made.
    My page :: Coupon Codes

    ReplyDelete

Search This Blog