Skip to main content
removed while..wend as async=false in this version
Source Link
JMP
  • 345
  • 1
  • 17

I can make a simple API call in JavaScript using XMLHttpRequest:

    <html>
    
    <script>
        function reqListener () {
            out.textContent=this.responseText;
        }
    
    var oReq = new XMLHttpRequest();
    oReq.addEventListener("load", reqListener);
    oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
    oReq.send();
        </script>
        
        <body><span id='out'></span></body>
    </html>

using the code from:

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

The same code in Excel:

Dim xh As Object
Set xh = CreateObject("MSXML2.serverXMLHTTP")

seurl = "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow"
          
xh.Open "GET", seurl, False
xh.Send

While xh.ReadyState <> 4
DoEvents
Wend

MsgBox xh.responseText

doesn't work, I get a return of '?[]'.

I can't see any difference. Why does the first one work and not the second?

I have read:

https://api.stackexchange.com/docs/compression

on compression, but the GET request seems to return a text file, at least in the JavaScript version.

I can make a simple API call in JavaScript using XMLHttpRequest:

    <html>
    
    <script>
        function reqListener () {
            out.textContent=this.responseText;
        }
    
    var oReq = new XMLHttpRequest();
    oReq.addEventListener("load", reqListener);
    oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
    oReq.send();
        </script>
        
        <body><span id='out'></span></body>
    </html>

using the code from:

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

The same code in Excel:

Dim xh As Object
Set xh = CreateObject("MSXML2.serverXMLHTTP")

seurl = "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow"
          
xh.Open "GET", seurl, False
xh.Send

While xh.ReadyState <> 4
DoEvents
Wend

MsgBox xh.responseText

doesn't work, I get a return of '?[]'.

I can't see any difference. Why does the first one work and not the second?

I have read:

https://api.stackexchange.com/docs/compression

on compression, but the GET request seems to return a text file, at least in the JavaScript version.

I can make a simple API call in JavaScript using XMLHttpRequest:

    <html>
    
    <script>
        function reqListener () {
            out.textContent=this.responseText;
        }
    
    var oReq = new XMLHttpRequest();
    oReq.addEventListener("load", reqListener);
    oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
    oReq.send();
        </script>
        
        <body><span id='out'></span></body>
    </html>

using the code from:

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

The same code in Excel:

Dim xh As Object
Set xh = CreateObject("MSXML2.serverXMLHTTP")

seurl = "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow"
          
xh.Open "GET", seurl, False
xh.Send

MsgBox xh.responseText

doesn't work, I get a return of '?[]'.

I can't see any difference. Why does the first one work and not the second?

I have read:

https://api.stackexchange.com/docs/compression

on compression, but the GET request seems to return a text file, at least in the JavaScript version.

added 185 characters in body
Source Link
JMP
  • 345
  • 1
  • 17

I can make a simple API call in JavaScript using XMLHttpRequest:

<html>

<script>
    function reqListener () {
        out.textContent=this.responseText;
    }

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
oReq.send();
    </script>
    
    <body><span id='out'></span></body>
</html>

    <html>
    
    <script>
        function reqListener () {
            out.textContent=this.responseText;
        }
    
    var oReq = new XMLHttpRequest();
    oReq.addEventListener("load", reqListener);
    oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
    oReq.send();
        </script>
        
        <body><span id='out'></span></body>
    </html>

using the code from:

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

The same code in Excel:

Dim xh As Object
Set xh = CreateObject("MSXML2.serverXMLHTTP")

seurl = "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow"
          
xh.Open "GET", seurl, False
xh.Send

While xh.ReadyState <> 4
DoEvents
Wend

MsgBox xh.responseText

doesn't work, I get a return of '?[]'.

I can't see any difference. Why does the first one work and not the second?

I have read:

https://api.stackexchange.com/docs/compression

on compression, but the GET request seems to return a text file, at least in the JavaScript version.

I can make a simple API call in JavaScript using XMLHttpRequest:

<html>

<script>
    function reqListener () {
        out.textContent=this.responseText;
    }

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
oReq.send();
    </script>
    
    <body><span id='out'></span></body>
</html>

using the code from:

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

The same code in Excel:

Dim xh As Object
Set xh = CreateObject("MSXML2.serverXMLHTTP")

seurl = "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow"
          
xh.Open "GET", seurl, False
xh.Send

While xh.ReadyState <> 4
DoEvents
Wend

MsgBox xh.responseText

doesn't work, I get a return of '?[]'.

I can't see any difference. Why does the first one work and not the second?

I have read:

https://api.stackexchange.com/docs/compression

on compression, but the GET request seems to return a text file, at least in the JavaScript version.

I can make a simple API call in JavaScript using XMLHttpRequest:

    <html>
    
    <script>
        function reqListener () {
            out.textContent=this.responseText;
        }
    
    var oReq = new XMLHttpRequest();
    oReq.addEventListener("load", reqListener);
    oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
    oReq.send();
        </script>
        
        <body><span id='out'></span></body>
    </html>

using the code from:

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

The same code in Excel:

Dim xh As Object
Set xh = CreateObject("MSXML2.serverXMLHTTP")

seurl = "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow"
          
xh.Open "GET", seurl, False
xh.Send

While xh.ReadyState <> 4
DoEvents
Wend

MsgBox xh.responseText

doesn't work, I get a return of '?[]'.

I can't see any difference. Why does the first one work and not the second?

I have read:

https://api.stackexchange.com/docs/compression

on compression, but the GET request seems to return a text file, at least in the JavaScript version.

Source Link
JMP
  • 345
  • 1
  • 17

Why doesn't my XMLHttpRequest call work in Excel?

I can make a simple API call in JavaScript using XMLHttpRequest:

<html>

<script>
    function reqListener () {
        out.textContent=this.responseText;
    }

var oReq = new XMLHttpRequest();
oReq.addEventListener("load", reqListener);
oReq.open("GET", "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow");
oReq.send();
    </script>
    
    <body><span id='out'></span></body>
</html>

using the code from:

https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest

The same code in Excel:

Dim xh As Object
Set xh = CreateObject("MSXML2.serverXMLHTTP")

seurl = "https://api.stackexchange.com/2.3/tags?order=desc&sort=popular&site=stackoverflow"
          
xh.Open "GET", seurl, False
xh.Send

While xh.ReadyState <> 4
DoEvents
Wend

MsgBox xh.responseText

doesn't work, I get a return of '?[]'.

I can't see any difference. Why does the first one work and not the second?

I have read:

https://api.stackexchange.com/docs/compression

on compression, but the GET request seems to return a text file, at least in the JavaScript version.