Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27340

XMLHttpRequest and Google Chrome

From Robbie Brown <rob@example.com>
Newsgroups comp.lang.javascript
Subject XMLHttpRequest and Google Chrome
Date 2015-04-12 19:36 +0100
Organization A noiseless patient Spider
Message-ID <mgedt0$ki9$1@dont-email.me> (permalink)

Show all headers | View raw



Chrome 41.0.2272.118
Windows 8.1

Chrome 41.0.2272.118
Ubuntu 12.10

Chrome 26.0.1410.43
Ubuntu 12.04 LTS

all 64bit

I'm having a problem with asynch' javascript requests in the above 
versions of Chrome on the above platforms. The same code works fine in 
various versions of Firefox and Opera on the above platforms.

The problem is worst on Ubu 12.10, not so bad but annoyingly frequent on 
Win 8.1 and hardly happens at all on Ubu 12.04 LTS

Here's the admittedly old function I call to get an XMLHttpRequest object

function newXMLHttpRequest() {

   var xmlreq = false;

   if (window.XMLHttpRequest) {
     // Create XMLHttpRequest object in non-Microsoft browsers
     xmlreq = new XMLHttpRequest();

   }
   else if (window.ActiveXObject) {
     try {
         xmlreq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
     }
     catch(e){
         try {
           // Try to create XMLHttpRequest in later versions
           // of Internet Explorer
           xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
         }
         catch (e1) {
           // Failed to create required ActiveXObject
           try {
             // Try version supported by older versions
             // of Internet Explorer
             xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
           }
           catch (e2) {

             // Unable to create an XMLHttpRequest with ActiveX
           }
         }
       }
     }
    return xmlreq;
}

and here's a function I call when a page is loaded

function getCart(){
     var req = newXMLHttpRequest();
      req.onreadystatechange = getReadyStateHandler(req, updateCart);
      req.open("POST", "common/ManageCart?cartmode=crtget", true);
      req.setRequestHeader("Content-Type", 
"application/x-www-form-urlencoded");
      req.send("");
}

updateCart uses javascript DOM to update the innerHTML property of a <div>

The error in the Chrome javascript console is

Uncaught TypeError: Cannot set property 'innerHTML' of null

Like I say, it's only Chrome that has this problem frequently enough to 
be a problem

Any ideas on what might be causing this problem in Chrome greatly 
appreciated

Thanks

Rob


-- 
Not floundering ... just fishing

Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-12 19:36 +0100
  Re: XMLHttpRequest and Google Chrome JJ <jj4public@vfemail.net> - 2015-04-13 12:33 +0700
    Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 07:41 +0100
  Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 11:30 +0200
    Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 11:50 +0100
      Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 13:17 +0100
        Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 13:34 +0100
          Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 14:26 +0100
          Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 16:15 +0200
            Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 16:03 +0100
              Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 19:26 +0200
                Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 20:23 +0200
          Re: XMLHttpRequest and Google Chrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-13 15:50 +0100
            Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 16:10 +0100
              Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 17:46 +0200
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 17:28 +0100
                Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 19:14 +0200
                Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 18:29 +0100
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 18:59 +0100
                Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 20:29 +0200
                Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 19:34 +0100
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 20:11 +0100
                Re: XMLHttpRequest and Google Chrome "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-13 20:44 +0200
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 20:21 +0100
                Re: XMLHttpRequest and Google Chrome Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-14 12:43 +0000
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-14 14:50 +0100
                Re: XMLHttpRequest and Google Chrome Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-14 22:51 +0200
                Re: XMLHttpRequest and Google Chrome Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-13 22:28 +0200
  Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 19:23 +0100
    Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 19:38 +0100
  Re: XMLHttpRequest and Google Chrome "Leonardo Azpurua" <leonardo@exmvps.org> - 2015-04-13 17:36 -0430
  Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-14 11:35 +0100
  Re: XMLHttpRequest and Google Chrome Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-14 11:37 +0000

csiph-web