Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    South East UK. 35 miles east of London, in sight of the River Thames.
    Posts
    300
    Thanks
    10
    Thanked 0 Times in 0 Posts

    ajax and IE8 not loading

    Hi All,

    I am using a simple ajax routine to fill a div with the results of a database query. My application is written in classic asp (Don't laugh!). Everything works fine in all browsers except IE8. This was not a problem until I picked up a client who is stuck with IE8.

    In IE8 the div's remain empty. Looking through the posts, it appears that IE8 has a problem with 'innerhtml'. Is this true and has anyone the solution to this IE8 issue?

    Cheers

    Gary

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,455
    Thanks
    23
    Thanked 631 Times in 630 Posts
    Everyone has a problem with 'innerhtml' because it's innerHTML js is case sensitive.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    South East UK. 35 miles east of London, in sight of the River Thames.
    Posts
    300
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Hi Sunfighter,

    I forgot to hit the shift key. This is the code I use.

    Cheers

    Gary

    =========================================

    Code:
    var xmlhttp
    
    function getData(str,file,target)
    {
    getData.file=file
    getData.target=target
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
      {
      alert ("Your browser does not support AJAX!");
      return;
      }
    var url=getData.file;
    
    url=url+"?q="+str;
    url=url+"&sid="+Math.random();
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
    }
    
    function stateChanged()
    {
    if (xmlhttp.readyState==4)
      {
      document.getElementById(getData.target).innerHTML=xmlhttp.responseText;
      }
    }
    
    function GetXmlHttpObject()
    {
    if (window.XMLHttpRequest)
      {
      // code for IE7+, Firefox, Chrome, Opera, Safari
      return new XMLHttpRequest();
      }
    if (window.ActiveXObject)
      {
      // code for IE6, IE5
      return new ActiveXObject("Microsoft.XMLHTTP");
      }
    return null;
    }

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,455
    Thanks
    23
    Thanked 631 Times in 630 Posts
    I'm a little suprised that this just don't work in IE8.
    Change xmlhttp.onreadystatechange=stateChanged;
    To xmlhttp.onreadystatechange = function() { stateChanged(); };
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #5
    Regular Coder
    Join Date
    Sep 2002
    Location
    South East UK. 35 miles east of London, in sight of the River Thames.
    Posts
    300
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sunfighter View Post
    I'm a little suprised that this just don't work in IE8.
    Change xmlhttp.onreadystatechange=stateChanged;
    To xmlhttp.onreadystatechange = function() { stateChanged(); };
    Hi Sunfighter,

    IE8 is still refusing to load the div. I'll upload the relevant snippets of code I am using in case I have done something stupid.

    Cheers

    Gary

  • #6
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,455
    Thanks
    23
    Thanked 631 Times in 630 Posts
    Try this for the IE section:
    if (window.ActiveXObject){
    return new ActiveXObject("Msxml2.XMLHTTP");
    }catch (e){
    try {
    return new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e) {}
    }
    }
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #7
    Regular Coder
    Join Date
    Sep 2011
    Posts
    341
    Thanks
    3
    Thanked 36 Times in 36 Posts
    Quote Originally Posted by Gary Williams View Post
    Everything works fine in all browsers except IE8. This was not a problem until I picked up a client who is stuck with IE8.
    As far as I know and notice in practice, IE8 and 9 support the same Ajax request method. And have the same problems with innerHTML, in that they only support that when the target element is not an element that standard has children. They have problems inserting e.g. <option> into <select>, but inserting an Ajax response into a <div> or <span> goes well.

    Could it be that your client has his IE8 in Compatibility View/Mode (= IE7)? You might wanna try to add an X-UA tag to the head of the page. If that solves it, he indeed has/had.
    Last edited by Frankie; 05-31-2014 at 08:07 PM.

  • #8
    New Coder
    Join Date
    Jun 2005
    Location
    Blackpool. UK
    Posts
    98
    Thanks
    0
    Thanked 4 Times in 4 Posts
    IE6 - IE8 have/had a problem with the XMLHTTP object, where it does not release the object after use


    Technical Articles: Reusing XMLHttpRequest Object in IE
    Chris

    Indifference will be the downfall of mankind, but who cares?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •