[Answered ]-Django spinner when loading (spin.js)

2👍

The spinner freezes because the browser has changed the page and is waiting for the new page to respond.

You could try using an animated gif as a spinner instead of spin.js, but that would probably freeze too.

If your verification process really needs to take 10+ seconds, then your best option is to submit the POST using Ajax, and then redirect or display the response once the server responds.

How you do it with Ajax depends on your workflow. The easiest way to POST by Ajax is with jQuery, if you don’t mind an extra library. Once it responds show the response in a div on the page or redirect to another view.

$.ajax({
    url: "/testScript/",
    method: "POST",
    data: { //form data
    },
    success: function(data) {
        //Display response here
    },
    complete: function() {
        //Hide spinner here
    }
});

This is pretty barebones since I don’t have enough details about your application or markup, but there are lots of similar solutions on here to help you.

Leave a comment