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


Groups > comp.lang.javascript > #36642

Re: Animation playing WHILE a form is submitted

Newsgroups comp.lang.javascript
Date 2019-05-23 02:32 -0700
References (1 earlier) <1b8eabbd-52c0-42a4-9046-700da3a5ef3e@googlegroups.com> <XnsAA56E64C5E695eejj99@194.109.6.166> <097f43c9-4a5e-49d5-83ad-efa9b46d55bc@googlegroups.com> <XnsAA577DE55F415eejj99@194.109.6.166> <bcd552a3-dd39-4e33-8535-3f54106f278c@googlegroups.com>
Message-ID <1dc5a5a0-e03a-403d-b601-03247935013b@googlegroups.com> (permalink)
Subject Re: Animation playing WHILE a form is submitted
From Julio Di Egidio <julio@diegidio.name>

Show all headers | View raw


On Wednesday, 22 May 2019 15:05:31 UTC+2, gro...@cyberdude.com  wrote:

>      var queryString = "?subject=" + subject + "&message=" + message;

That's guaranteed to break, it should be:

  var queryString = "?subject=" + encodeURIComponent(subject) + ...

<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent>

> I've seen this code on the net

RTFM first, at least get an idea what's in there, then look at examples.

> > >         setTimeout (function() {
> > >          request.onreadystatechange=null; // to negate the handler

To abort a request you should use the abort method:

<https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/abort>

> what I want to do is to cancel anything happening if the OTHER
> "onreadystatechange" handler is triggered

Here is the basic scheme (slightly expanded re what I had already posted):

- Unset a global flag just before sending the request.
- In the onreadystatechange handler, first check the flag: if it is set,
  don't do anything, otherwise proceed as usual.
- In the timeout handler, first set the flag then (optionally) abort the
  request.

This scheme works under the assumption that no request is sent while another
is in progress (because of the one global variable).  To do better than that,
you'll need closures rather than just a global variable.  Anyway this can come
later, the basic code remains the same.

HTH,

Julio

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


Thread

Animation playing WHILE a form is submitted groovee@cyberdude.com - 2019-05-15 20:58 -0700
  Re: Animation playing WHILE a form is submitted groovee@cyberdude.com - 2019-05-21 05:18 -0700
    Re: Animation playing WHILE a form is submitted "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-21 22:38 +0200
      Re: Animation playing WHILE a form is submitted Julio Di Egidio <julio@diegidio.name> - 2019-05-21 14:40 -0700
        Re: Animation playing WHILE a form is submitted "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-22 00:07 +0200
      Re: Animation playing WHILE a form is submitted groovee@cyberdude.com - 2019-05-21 23:38 -0700
        Re: Animation playing WHILE a form is submitted "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-22 12:22 +0200
          Re: Animation playing WHILE a form is submitted groovee@cyberdude.com - 2019-05-22 06:05 -0700
            Re: Animation playing WHILE a form is submitted groovee@cyberdude.com - 2019-05-22 06:27 -0700
              Re: Animation playing WHILE a form is submitted "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-23 09:17 +0200
            Re: Animation playing WHILE a form is submitted Julio Di Egidio <julio@diegidio.name> - 2019-05-23 02:32 -0700
              Re: Animation playing WHILE a form is submitted Julio Di Egidio <julio@diegidio.name> - 2019-05-23 03:16 -0700
                Re: Animation playing WHILE a form is submitted groovee@cyberdude.com - 2019-05-24 04:24 -0700

csiph-web