Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #39192
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Sending a short message to a server |
| Date | 2020-11-25 13:55 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1913393.oMNUckLgyt@PointedEars.de> (permalink) |
| References | <message-20201123133048@ram.dialup.fu-berlin.de> |
Stefan Ram wrote:
> Assume, you want to send a short message to a Web server.
>
> For example, »screenwidth=1200«.
> […]
>
> Issue an AJAX request with a similar URI: request.open
> ( "GET", "http://server/cgi?screenwidth=1200" ... );
“AJAX” is as much a thing of the past as is CGI. Moreover, without a
subsequent request.send(null), nothing considerable will happen.
> What's the recommendable way to do something like this today?
If it is a text message, then
fetch('…?msg=' + encodeURIComponent('screenwidth=1200'));
Otherwise,
fetch('…?screenwidth=1200');
If PATH_INFO support is enabled,
fetch('…/screenwidth=1200');
can work, too.
In general, if there are no backwards compatibility considerations,
the Fetch API is the way to go.
<https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API>
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread
Re: Sending a short message to a server Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-11-25 13:55 +0100
csiph-web