A
A
Andrey Demidenko2015-04-06 09:26:14
JavaScript
Andrey Demidenko, 2015-04-06 09:26:14

How to display a message on ajax request?

I'm trying to go to action using ajax request. The action is prohibited by the CanCanCan gem.
The message that the action is prohibited is displayed only on the next page. How to display a message on the current page?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Vsk, 2015-04-06
@Dem1

Poorly I understand, than the code of views and ability here will help.
But, most likely, you have
redirect_to ..., error: 'Error message'
or
flash ..., error: 'Error message' in your controller
So you need to use it
There should be an action.js template. erb
or in the script itself, there must be an error event handling.
And there you need to manually call the desired message. Type:
$("#error").text('Error message').show();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question