Home » Jquery » javascript – Load HTML file to replace div content on button press

javascript – Load HTML file to replace div content on button press

Posted by: admin February 22, 2020 Leave a comment

Questions:

Currently I have some code, which will process a progress bar when submit button is pressed. However I am wondering how I can make it so that on the first submit, it sends you to a static html file which replaces the content inside of our .container div, then after the second button submit it completes the iteration as directed.

Here’s the code.

$("#loading").hide();
$("#submit").click(function () {
    if ($("#inputUsername").val().length > 2) {
        $("#inputForm").hide();
        $("#loading").show();
        setTimeout(function () {
            $("#status").text("Connecting to server...");
            $("#loadingbar").attr("aria-valuenow", "20").css("width", "20%").text("20%");
            setTimeout(function () {
                $("#status").text("Accessing database...");
                $("#loadingbar").attr("aria-valuenow", "40").css("width", "40%").text("40%");
                setTimeout(function () {
                    $("#status").text("Fetching user data...");
                    $("#loadingbar").attr("aria-valuenow", "60").css("width", "60%").text("60%");
                    setTimeout(function () {
                        $("#status").text("Human verification required...");
                        $("#loadingbar").attr("aria-valuenow", "80").css("width", "80%").text("80%");
                        setTimeout(function () {
                            var isMobile = /iPhone|iPad|iPod|Android|WebOS|iOS/i.test(navigator.userAgent);
                            if (isMobile) {
                                window.location = "https://example.com";
                            } else {
                                window.location = "https://example.com";
                            }
                        }, 2000);
                    }, 2000);
                }, 2000);
            }, 2000);
        }, 2000);
    } else {
        alert('Invalid username')
    }
})

Desired Solution.

// User submits their username, selects a value. Presses submit, it takes them to a second page, they fill out some data, then press submit again. The progress bar continues, and then sends them to the window.location field.

How to&Answer: