javascript - Update a controller variable with ajax in rails? -
i trying update variable in view after clicking on table row. right have javascript function:
$("#mytable tr").click(function(){ var rowdata = $(this).children("td").map(function() { return $(this).text(); }).get(); var id = $.trim(rowdata[0]); $.ajax({ ... }); })
i want pass variable "id" controller can update in view. don't know go inside ajax call. don't know go inside controller know need use respond_to not sure else.
you have write code:
$.ajax({ type: "post", url: <%= path_of_controller_action %>, data: { data want send }, beforesend: function() { $form.find(':input').prop('disabled', true); $form.find('.ajax-in-progress').removeclass('hidden'); return daisy.ajax_loader(true, 'waiting', 'small'); }, success: function(data) { return location.reload(); }, error: function(e) { alert("oops! error occurred, please try again"); return console.log(e); } });
i f want should use datatable ajax
Comments
Post a Comment