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


Groups > comp.lang.javascript > #39192 > unrolled thread

Re: Sending a short message to a server

Started byThomas 'PointedEars' Lahn <PointedEars@web.de>
First post2020-11-25 13:55 +0100
Last post2020-11-25 13:55 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.javascript

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Sending a short message to a server Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-11-25 13:55 +0100

#39192 — Re: Sending a short message to a server

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2020-11-25 13:55 +0100
SubjectRe: Sending a short message to a server
Message-ID<1913393.oMNUckLgyt@PointedEars.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.

[toc] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web