K
K
Karina2016-07-15 18:27:24
Ruby on Rails
Karina, 2016-07-15 18:27:24

How to make preloader on send_data?

There is an action that, upon request, pumps out a large amount of data. How to let the user know that his request is being fulfilled? AJAX is not an option - send_data doesn't work. In Resque.enqueue send_data doesn't work either. What to do?
Thanks everyone for the replies.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-07-16
@iKapex

You can add to the button:
And also by pressing it with the help of JavaScript, you can turn all the fields into "read-only", and also with the help of the same JavaScript you can display an animated icon (see fa-spin at Font Awesome) and an inscription next to it, they say : "Please wait. Your request is being processed."
Or is it better to do so. Add this to the form:
Next, look at the ID of the form and add a JS handler (CoffeeScript):

$(document).ready ->
  $("#form-id").on("ajax:success", (e, data, status, xhr) ->
    #	Тут какой-нибудь код, когда все хорошо. Передаваемый JSON доступен в data.
  ).on "ajax:error", (e, xhr, status, error) ->
    #	Тут какой-нибудь код, когда все очень плохо.
return

As a result, if success or error, then hide the form and progress, and then one or another message is displayed in place of all this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question