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


Groups > comp.lang.javascript > #36674

Animation playing while a form is submitted, part 2

Newsgroups comp.lang.javascript
Date 2019-05-30 04:45 -0700
Message-ID <85019acc-df74-4e53-9997-a92ca2f1f9d1@googlegroups.com> (permalink)
Subject Animation playing while a form is submitted, part 2
From groovee@cyberdude.com

Show all headers | View raw


Hi guys,
I'm trying to submit a form via AJAX and have an animation play while it submits, but it's not working. I've got this, right up top:

    function ajaxFunction(e){
        e.preventDefault();
        blah blah
        var spin = true;


Then:
        ajaxRequest.onload = function() {
	var spin = false;
	var ack =  ajaxRequest.responseText;
        if (ack === "OK") { ajaxDisplay.innerHTML = "Message Sent"; }
        };

Then:
       	ajaxRequest.ontimeout = function (e) {
	var spin = false;
	ajaxDisplay.innerHTML = "Message NOT Sent";// XMLHttpRequest timed out. Do something here.
	};

        blah blah

And finally (a pink box has to spin infinitely until the response comes back):
        ajaxRequest.send(null);
        
        var pinkbox = document.getElementById('container');
        while (spin === true) {
		pinkbox.style.transition="transform 1s";	//spin the box;
		pinkbox.style.transform="rotate3d(1,0,0,360deg)";
		}


But it BLOCKS when "submit" is clicked, and then Firefox says "Wait" or "Stop your webpage", and if I click "Wait", then the box spins ONCE! :( What am I doing wrong??

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


Thread

Animation playing while a form is submitted, part 2 groovee@cyberdude.com - 2019-05-30 04:45 -0700
  Re: Animation playing while a form is submitted, part 2 Julio Di Egidio <julio@diegidio.name> - 2019-05-30 09:41 -0700
    Re: Animation playing while a form is submitted, part 2 Julio Di Egidio <julio@diegidio.name> - 2019-05-30 09:47 -0700
      Re: Animation playing while a form is submitted, part 2 groovee@cyberdude.com - 2019-05-30 22:56 -0700
        Re: Animation playing while a form is submitted, part 2 groovee@cyberdude.com - 2019-05-31 00:22 -0700
        Re: Animation playing while a form is submitted, part 2 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 09:31 +0200
          Re: Animation playing while a form is submitted, part 2 groovee@cyberdude.com - 2019-05-31 01:11 -0700
            Re: Animation playing while a form is submitted, part 2 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 10:52 +0200
        Re: Animation playing while a form is submitted, part 2 Julio Di Egidio <julio@diegidio.name> - 2019-05-31 00:33 -0700
          Re: Animation playing while a form is submitted, part 2 groovee@cyberdude.com - 2019-05-31 01:13 -0700
            Re: Animation playing while a form is submitted, part 2 Jon Ribbens <jon+usenet@unequivocal.eu> - 2019-05-31 11:11 +0000
    Re: Animation playing while a form is submitted, part 2 groovee@cyberdude.com - 2019-05-30 22:51 -0700
  Re: Animation playing while a form is submitted, part 2 groovee@cyberdude.com - 2019-05-31 01:16 -0700
    Re: Animation playing while a form is submitted, part 2 "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-05-31 10:57 +0200

csiph-web