Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 822893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:51:50+00:00 2026-05-15T02:51:50+00:00

The following code executes fine in Firefox and Chrome, but gives an error: ‘null’

  • 0

The following code executes fine in Firefox and Chrome, but gives an error:

'null' is null or not an object

when executed in Internet Explorer.

if (xmlhttp.responseXML != null)
    {
    var xmlDoc = xmlhttp.responseXML.documentElement ;
    var ResultNodes = xmlDoc.getElementsByTagName ("Result") ;   <---- error here
    if (ResultNodes != null)
        {

(I would have thought the line after the one indicated would be more likely to return the error but the debugger says the run-time error is at the line indicated)

Any ideas why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:51:50+00:00Added an answer on May 15, 2026 at 2:51 am

    Thought I would just report back my findings, now that I have it all working. The following client-side code (slightly abridged and anonymized) contains all the work-arounds I needed to address the prblems outlined in this thread and works on IE (8.0.6001), FF(3.5.9), and Chrome (5.0.375.55 beta). Still yet to test under older versions of browsers. Many thanks to all who responded.

    I should also add that I needed to make sure that the server response needed to include:

    Response.ContentType = "text/xml" ;
    

    for it to work with IE. FF didn’t mind if the ContentType was text/HTML but IE coughed.

    Code to create an XMLHTTP request:

    function GetXMLHTTPRequest () 
    {
    var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] ; //activeX versions to check for in IE
    if (window.ActiveXObject)  //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
        {
        for (var i=0; i < activexmodes.length ; i++)
            {
            try
                {
                return new ActiveXObject(activexmodes[i]) ;
                }
            catch (e)
                {    //suppress error
                }
            }
        }
     else if (window.XMLHttpRequest) // if Mozilla, Safari etc
        {
        return new XMLHttpRequest () ;
        }
     else
        {
        return (false) ;
        }
    }
    

    Code to return the text value of a record node:

    function GetRecordElement (ARecordNode, AFieldName)
    {
    try
        {
        if (ARecordNode.getElementsByTagName (AFieldName) [0].textContent != undefined)
            {
            return (ARecordNode.getElementsByTagName (AFieldName) [0].textContent) ; // Chrome, FF
            }
    
        if (ARecordNode.getElementsByTagName (AFieldName) [0].text != undefined)
            {
            return (ARecordNode.getElementsByTagName (AFieldName) [0].text) ;  //  IE
            }
    
        return ("unknown") ;    
        }
    catch (Exception)
        {
        ReportError ("(GetRecordElement): " + Exception.description) ;
        }
    }
    

    Code to perform the AJAX request:

    function GetRecord (s)
    {
    try 
        {
        ReportStatus ("") ;
    
        var xmlhttp = GetXMLHTTPRequest () ;
        if (xmlhttp)
            {
            xmlhttp.open ("GET", "blahblah.com/AJAXget.asp?...etc", true) ;
    
            if (xmlhttp.overrideMimeType) 
                {
                xmlhttp.overrideMimeType("text/xml") ;
                }
            xmlhttp.setRequestHeader ("Content-Type", "text/xml; charset=\"utf-8\"") ; 
    
            xmlhttp.onreadystatechange = function () 
                {
                if (xmlhttp.readyState == 4) 
                    {
                    if (xmlhttp.responseXML != null)
                        {
                        var xmlDoc = xmlhttp.responseXML;                
                        var ResultNodes = xmlDoc.getElementsByTagName ("Result") ;
                        if (ResultNodes != null)
                            {
                            var PayloadNode = xmlDoc.getElementsByTagName ("Payload") ;
                            if (PayloadNode != null)
                                {
                                var ResultText = ResultNodes [0].firstChild.nodeValue ;
                                if (ResultText == "OK")
                                    {
                                    ReportStatus (ResultText) ;
                                    var RecordNode  = PayloadNode [0].firstChild ;
                                    if (RecordNode != null)
                                        {
                                        UpdateRecordDisplay (RecordNode) ; // eventually calls GetRecordElement 
                                        }
                                    else
                                        {
                                        ReportError ("RecordNode is null") ;
                                        }
                                    }
                                else
                                    {
                                    ReportError ("Unknown response:" + ResultText) ;
                                    }             
                                }    
                            else
                                {
                                ReportError ("PayloadNode is null") ;
                                }
                            }    
                        else
                            {
                            ReportError ("ResultNodes is null") ;
                            }
                        }
                    else   
                        {
                        ReportError ("responseXML is null") ;
                        }
                    }    
                else
                    {  
                    ReportStatus ("Status=" + xmlhttp.readyState) ;
                    }
                }    
    
            ReportStatus ("Requesting data ...") ;
            xmlhttp.send (null) ;
            }
        else
            {
            ReportError ("Unable to create request") ;
            }        
        }
    catch (err)
        {
        ReportError ("(GetRecord): " + err.description) ;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.