How to create a loading without AJAX

Asked

Viewed 47 times

0

I have a download button that makes a GET request that makes a Download. It all happens on the same page, but without AJAX.

Not using the tag download. Is using the Laravel that internally makes the download service.

I would like a message to appear on the button when pressing the Download button same "Wait...".

When you finished the page loading process and started the download, return the previous message from the button.

I tried to do it like this, but it doesn’t work:

$('.btn-export').on('click', function(){
    $(this).text('EXPORTANDO...');

    $(window).on('load', function(){
        $('.btn-export').text('EXPORTAR');
    });
});

Any idea?

  • If you could say which part does not work: changing the text or returning the text, or both.

  • What the text returns to.

  • Look, the $(window). on(load... will not take effect inside the onclick button... put it outside so that the page can perform it when it is loaded

  • It doesn’t work. I’ve tried.

  • Just so I’m clear: this whole process takes place without page refresh?

  • From what I understand, when you click the button download, the page is reloaded. Is that it? If so, what you should do is delay loading the page so that the display of $(this).text('EXPORTANDO...'); is visible. Otherwise, the page will reload and you will lose all dynamic modifications on GIFT. This delay is not a good practice in my opinion. Already the $(window).on('load', ...); has no use within the scope of the button.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.