views:

84

answers:

3

window.onload = function(){ testAjax(); }

var testAjax = function(){
  var request = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  request.onreadystatechange = function(){
    if (request.readyState == 4){
      // Server is done
       try{
        var p = document.getElementById['a'];
        p.innerHTML = request.responseText;
         //document.write(request.responseText);
       }
       catch(e){
        document.write('More Epic Fail');
       }
    }
  }
  request.open('GET','updatethumbs.php',true);
  request.send(null);
}
+2  A: 

getElementById should have ()'s, not []'s

Donnie DeBoer
+3  A: 

After a quick glance:

var p = document.getElementById['a'];

should be:

var p = document.getElementById('a');
o.k.w
A: 

Yup, use "rounded brackets"/parenthesis ()

There are a few names for the MSXML component and depending on what the user (in this case, you) has installed, it may not work.

EDIT: (as per question edit)

Browsers are not required to redraw the page once it's been rendered according to the CSS spec. You need to use javascript to style the items that are dynamically added in.Try, for example:

document.getElementById('a').style.border = "1px solid black";

for a simple black border.

Moshe