Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36629
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Animation playing WHILE a form is submitted |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <b57b24ab-436b-4cb2-a1fd-be3cd3b7c9a1@googlegroups.com> <1b8eabbd-52c0-42a4-9046-700da3a5ef3e@googlegroups.com> <XnsAA56E64C5E695eejj99@194.109.6.166> <097f43c9-4a5e-49d5-83ad-efa9b46d55bc@googlegroups.com> |
| Date | 2019-05-22 12:22 +0200 |
| Message-ID | <XnsAA577DE55F415eejj99@194.109.6.166> (permalink) |
groovee@cyberdude.com wrote on 22 May 2019 in comp.lang.javascript:
> On Wednesday, 22 May 2019 02:08:27 UTC+5:30, Evertjan. wrote:
>>
>> Please quote what you are referring to, this is usenet, not email.
>
>
> Can you not read the FIRST POST in this thread, for whatever reason??!!
Usenet has no "treads" in that sense, postings are shown in different
newsservers in a rather random way, so NETIQUETTE requires to always quote
what you are responding on.
> Anyway:
>
> I have a form which will be submitted using AJAX,
Do you mean JSON?
> and I would like an
> animation (a *programmed* animation of some sort, NOT an animated GIF)
> to be played AFTER the user clicks "Submit".
After submit, unless you add a destination URL using
action <form action = '..URL..'>, the page is gone and the destination page
is being build up.
> However, after the user
> *does* click "Submit", if the form submission has not taken place
> correctly say, within 10 secs.,
So you are not form-submitting anything, just using the <form> format to
send something using a javascript script?
> (network outage or whatever), a "Message
> not sent" message should be displayed. If, within that time, the message
> HAS gone through, ie. the server has echoed "OK", then a "Message sent"
> message should be displayed. I was trying to work out how to do this. My
> original thought was, after the "request.send(null)", to do this:
I see.
> request.send(null);
> setTimeout (function() {
> request.onreadystatechange=null; // to negate the handler
> alert("Message not sent");
>}, 10000);
1 The onreadystatechange is asynchronous by itself, I think you cannot
expact an immediate response.
2 the alert() will stop any execution till responded to by enter or mouse-
click
>
> and then, this:
> request.onreadystatechange = blah blah alert("Message sent");
>
> But this is not having the effect I want.
Stands to reason,depending on what you wrongly expect to happen.
> I want the animation (ie. tampering with CSS in whatever way to do
> animation) to play WHILE the 10 secs passes, after the user has clicked
> Submit, and, if the "onreadystatechange" happens within that time, then
> say "Message sent". So - do I need to mess with multithreading or
> something do that?
Javascript is single-threaded.
Perhaps you should just do your animation by CSS or Javaascript till the
onreadystatechange fires as okay.
var xhttp = new XMLHttpRequest();
...
let stopIt = setTimeOut(== STOP YOUR ANIMATION HERE IF TOO LONG ==, 5000);
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
== STOP YOUR ANIMATION HERE == ;
== RESET stopIt timeout == ;
};
};
> I don't know much about it.
There is an excellent remedy for that:
Go and study!
Find out what others have done!
Don't ask for ready-to-consume solutions!
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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