Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Noty modal not closing on n.close()

The idea is to check if a certain page is available every second. When the page is available, I want to show a Noty-modal where user can choose to reload the current page or to close the modal. I use Noty.js v3.1.4.

JS Code

<script>
    var n = new Noty({
        text: "Website under construction",
        type: 'alert',
        layout: 'center',
        theme: 'bootstrap-v4',
        modal: 'true',
        buttons: [
            Noty.button("Yes", "btn btn-primary", function () {
                location.reload();
            }),
            Noty.button("No", "btn btn-primary ml-3", function () {
                checkAvailability = true;
                n.close();
            })],
        animation: {
            open: 'animated fadeIn faster',
            close: 'animated fadeOut faster'
        }
    });
    var checkAvailability = true;
    var timeout = 1000;
    
    (function(){
        if (checkAvailability) {    
            $.ajax({
                url: "https://example.com",
                type : 'HEAD',
                success : function(){
                    //website is available
                    checkAvailability = false;
                    timeout = 30000; // set timeout to 30 seconds, no need to check every second anymore
                    n.show();
                },
                error: function (){
                    //website is not available
                    checkAvailability = true;
                    timeout = 1000;
                }
            });
        }
        setTimeout(arguments.callee, timeout);
    })();
</script>

The AJAX request works and at a certain moment the Noty Modal shows up. Now when I click on 'No', the modal won't close. I see that n.closed changes from false to true, but the modal doesn't disappear. There is no log in the console. Any idea what's wrong?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!