dominoExperts.com - Powered by Domino 8.5.2 Domino Accelerator Pack
- Cache, Combine, JS-Minify and Compress content
Lotus Triple Search DominoExperts + Blogs + R8 forum
dominoExperts.com -> Script vault -> Ajax

 Small Ajax example


Tomas NielsenPost date: 2007-01-09 23:57

I found this on JavaScriptKit. It shows a nice way of including html on an already loaded page.

function HttpRequest(url){
var pageRequest = false //variable to hold ajax object
/*@cc_on
   @if (@_jscript_version >= 5)
      try {
      pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
      }
      catch (e){
         try {
         pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
         }
         catch (e2){
         pageRequest = false
         }
      }
   @end
@*/

if (!pageRequest && typeof XMLHttpRequest != 'undefined')
   pageRequest = new XMLHttpRequest()

if (pageRequest){ //if pageRequest is not false
   pageRequest.open('GET', url, false) //get page synchronously
   pageRequest.send(null)
   embedpage(pageRequest)
   }
}

function embedpage(request){
//if viewing page offline or the document was successfully retrieved online (status code=2000)
if (window.location.href.indexOf("http")==-1 || request.status==200)
   document.write(request.responseText)
}

HttpRequest("external.htm") //include "external.htm" onto current page


Michael HolmströmPost date: 2007-01-16 09:56
Note that Dominos form-tags can mess around with the Ajax-implementation in IE6. You´ll need to strip the form-tags from Domino html-output before pushing it into a div.

Fredrik StöckelPost date: 2007-01-16 10:26

This is true if you decide to return the complete rendered markup, most XHR implementations I have done either return JSON or XML... and sometimes just a js function call, then this isn't a problem.

If you want to return the complete rendered page, you have more things to take care of besides the form element... the html/head/body and so on are all elements that should only exist one time for a page to be considered valid (among other things)…


Michael HolmströmPost date: 2007-01-16 11:06
True indeed. However it "works" within IE with head/body tag and such. But it doesnt even work to render it if the div contains a form-tag.



RSS feed
Subscribe to Forum

Share this page

Top posters
Tomas Nielsen212
Joacim Boive27
Fredrik Stöckel27
Danne14
Niklas Waller13
Kenneth Haggman11
Bryan Kuhn10
Daniel Lehtihet9
Jonas Israelsson8
dm997