The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Dynamic page load not working (AJAX) Re: Dynamic page load not working (AJAX)


My teaches suggest me for that try this one
<script type="text/javascript">
//defining the request
var pageRequest = false //variable to hold ajax object
@if (@_jscript_version >= 5)
try {
pageRequest = new ActiveXObject("Msxml2.XMLHTTP")
catch (e){
try {
pageRequest = new ActiveXObject("Microsoft.XMLHTTP")
catch (e2){
pageRequest = false
if (!pageRequest && typeof XMLHttpRequest != ‘undefined’)
pageRequest = new XMLHttpRequest()

function include(content,id){
var newdiv = document.createElement("div");
newdiv.innerHTML = content;
remove(id); document.getElementById(id).appendChild(newdiv);

function remove(id)

if (pageRequest){

// add as many requests as you want; the variables holding them must be document.written in order to bring in external CODE‘GET’, ‘external1.html’, false)
pageRequest.send(null); ajax_include1=pageRequest.responseText;‘GET’, ‘external2.html’, false)
pageRequest.send(null); ajax_include2=pageRequest.responseText;

//needed for bringing in the external CODE
document.write(‘<div style="display:none">’);



<body >
<a href="javascript:void(0)" onclick=’include(ajax_include1,"div1");’>add external1.html</a><br>
<a href="javascript:void(0)" onclick=’include(ajax_include2,"div2");’>add external2.html</a><br><br>
<a href="javascript:void(0)" onclick=’remove("div1")’>remove external1.html</a><br>
<a href="javascript:void(0)" onclick=’remove("div2")’>remove external2.html</a><br>
<div id="div1" ></div>
<div id="div2" ></div>