javascript - Django spinner when loading (spin.js) -


i new in django , things, , need tips or solutions adding spinner. iam using spin.js, show on way:

 var target = document.getelementbyid('spin');     var spinner = new spinner(opts).spin(target);     spinner.stop();     function spin_stop()     {         spinner.stop();     }     function spin_start()     {         spinner.spin(target);     } 

this code copied example on web. show spinner <div id...>

now there problem.

i have app in django name testscript. app connects different page verify login information. "long" process, takes 10sec. in time, want on login page add spinner. in template have form:

<form class="form-signin" action="/testscript/" method="post"> 

and if want add onclick event in button in form, spinner freeze.

how can show spinner, when testscript processing?

thanx

the spinner freezes because browser has changed page , waiting new page respond.

you try using an animated gif spinner instead of spin.js, freeze too.

if verification process needs take 10+ seconds, best option submit post using ajax, , redirect or display response once server responds.

how ajax depends on workflow. easiest way post ajax jquery, if don't mind library. once responds show response in div on page or redirect view.

$.ajax({     url: "/testscript/",     method: "post",     data: { //form data     },     success: function(data) {         //display response here     },     complete: function() {         //hide spinner here     } }); 

this pretty barebones since don't have enough details application or markup, there lots of similar solutions on here you.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -