Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36635
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2019-05-22 06:05 -0700 |
| 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> <XnsAA577DE55F415eejj99@194.109.6.166> |
| Message-ID | <bcd552a3-dd39-4e33-8535-3f54106f278c@googlegroups.com> (permalink) |
| Subject | Re: Animation playing WHILE a form is submitted |
| From | groovee@cyberdude.com |
On Wednesday, 22 May 2019 15:52:39 UTC+5:30, Evertjan. wrote:
> > 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?
>
Correct. It will be something like this:
var subject = document.getElementById('subject').value;
var message = document.getElementById('message').value;
var queryString = "?subject=" + subject + "&message=" + message;
ajaxRequest.open("GET", "http://localhost/sendmessage.php" + queryString, true);
ajaxRequest.send(null);
(I've seen this code on the net - it IS correct, right? I mean, it IS the right way to do it??)
> > 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.
I don't really understand what you're saying, and I REALLY want to be sure I've got this right - what I want to do is to cancel anything happening if the OTHER "onreadystatechange" handler is triggered -ie. if the message gets sent OK AFTER 10 secs - is "request.onreadystatechange=null;" the right way to do that??
>
> 2 the alert() will stop any execution till responded to by enter or mouse-
> click
>
Oh the "alert" is just illustrative - I won't be using any alerts in the production site :)
> Javascript is single-threaded.
Er - aren't there WebWorkers?
>
> 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 == ;
> };
> };
>
>
Sorry I dont'get you - how do I stop the animation?? It has to play in a continuous loop until the "onreadystatechange" fires..? What does this line mean?:
let stopIt = setTimeOut..blah blah
And what does THIS mean?:
== RESET stopIt timeout == ;
> There is an excellent remedy for that:
>
> Go and study!
> Find out what others have done!
> Don't ask for ready-to-consume solutions!
By NO MEANS do I want a ready-to-consume solution - and I AM studying! :)
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