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


Groups > comp.lang.javascript > #38918

Re: IIS http.open "GET" error

Path csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.javascript
Subject Re: IIS http.open "GET" error
Date Fri, 9 Oct 2020 12:03:27 +0200
Lines 41
Message-ID <huaqreFqk7fU1@mid.individual.net> (permalink)
References <ebdc63ad-7565-4d6e-872e-90c9a8719f70o@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace individual.net xk8PowsRrVOB9QRC5Q54hgP3xToU10MeG/pQWIIxjtnP97pee2
Cancel-Lock sha1:E6DK5emKxaiU6a5r8uu0Pnj93d4=
In-Reply-To <ebdc63ad-7565-4d6e-872e-90c9a8719f70o@googlegroups.com>
Xref csiph.com comp.lang.javascript:38918

Show key headers only | View raw


Jonas Thörnvall:

> Just installed IIS on the new computer, the SPASSKY.JCH game will
> donwload from external internet service provider site but i can not
> get it download from localhost 127.0.0.1  IIS server. "the webserver
> start" it is just the get of file that fail on my server.
> 
> Is it just a filepath error or something else? The file resides at
> root level in IIS server.
> 
> function loadFile(filePath) { var result = null; var xmlhttp = new
> XMLHttpRequest(); xmlhttp.open("GET", filePath, false); 
> xmlhttp.send(); if (xmlhttp.status==200) { result =
> xmlhttp.responseText; } return result; }
[...]
> textFromFileLoaded=loadFile('SPASSKY.JCH'); 
> parse(textFromFileLoaded)
> 
> loadsave.js:62 Uncaught TypeError: Cannot read property 'split' of
> null at parse (loadsave.js:62) at chessInit (gameengine.js:14) at
> (index):130

1) Make sure IIS works at all - put the file named SPASSKY.JCH to the
root directory and check that http://localhost/SPASSKY.JCH or
http://127.0.0.1/SPASSKY.JCH gives you the content of that file.

2) XHR does not load "files" it will send a HTTP request for an *URL*.
Also see
<https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/open>.
Therefore you should also put the URL there and not just a file name.

3) Add error handling - there are many reasons why a request can fail.
Assuming a function which fetches data via XHR will always work and
always return data in a certain way will eventually cause security
problems. If loadFile() can return null then handle this case and don't
assume in parse() that there will always be a valid content.


-- 
Arno Welzel
https://arnowelzel.de

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


Thread

IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-07 08:23 -0700
  Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-07 08:34 -0700
    Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-07 08:35 -0700
  Re: IIS http.open "GET" error John G Harris <niam@jghnorth.org.uk.invalid> - 2020-10-07 18:01 +0100
    Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-07 10:18 -0700
      Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-07 11:51 -0700
        Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-07 11:59 -0700
          Re: IIS http.open "GET" error "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-07 21:14 +0200
          Re: IIS http.open "GET" error Julio Di Egidio <julio@diegidio.name> - 2020-10-07 17:20 -0700
            Re: IIS http.open "GET" error Julio Di Egidio <julio@diegidio.name> - 2020-10-07 17:30 -0700
              Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-07 19:26 -0700
                Re: IIS http.open "GET" error Frank Kozuschnik <franko@nurfuerspam.de> - 2020-10-08 10:38 +0200
                Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-08 02:07 -0700
                Re: IIS http.open "GET" error Julio Di Egidio <julio@diegidio.name> - 2020-10-08 05:49 -0700
                Re: IIS http.open "GET" error "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-10-08 15:22 +0200
                Re: IIS http.open "GET" error Julio Di Egidio <julio@diegidio.name> - 2020-10-08 06:30 -0700
  Re: IIS http.open "GET" error Arno Welzel <usenet@arnowelzel.de> - 2020-10-09 12:03 +0200
    Re: IIS http.open "GET" error Frank Kozuschnik <franko@nurfuerspam.de> - 2020-10-09 17:33 +0200
      Re: IIS http.open "GET" error Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-10-09 18:14 +0200
        Re: IIS http.open "GET" error Frank Kozuschnik <franko@nurfuerspam.de> - 2020-10-09 19:38 +0200
          Re: IIS http.open "GET" error Julio Di Egidio <julio@diegidio.name> - 2020-10-11 03:30 -0700
      Re: IIS http.open "GET" error Arno Welzel <usenet@arnowelzel.de> - 2020-10-09 23:49 +0200
    Re: IIS http.open "GET" error Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-10-09 11:06 -0700
      Re: IIS http.open "GET" error Arno Welzel <usenet@arnowelzel.de> - 2020-10-09 23:52 +0200

csiph-web