I have button with link. = link_to 'Preview', mail_templates_preview_path(mailer: @mail_template.mailer, name: @mail_template.name), id: 'some_id'
But i want add params when this button clicked. For this, i try
event.preventDefault();
$.ajax({
url: this.href,
type: 'GET',
data: { template_code: $('#ckeditor').val() },
});
And after i expect what rails redirect me to this.href
and render new page(../some_method.html.slim).
MyController
def some_method
@mail_template = do_something
end
end
How i can to do request from js to rails controller and render this controller's page?