I am trying to use the latest form_with to send an Ajax post.
Here is what I did.
<%= form_with url: comments_path, data: { type: :json } do |form| %>
<%= form.text_area :context, class: "rt-textarea mg-b-10" %>
<%= form.submit "Submit", class: "btn-m btn-blue, id: "comment-submit" %>
<% end >
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#comment-submit').on('ajax:success', function(event, data) {
console.log('GET RESPONSE!');
});
});
</script>
But when I send the form post, the console didn't print GET RESPONSE!.
I checked the Network tab in google developer console, it did send the JSON object back. Is there anything I miss?