I am working on a scenario where a <div> tag is refreshed using ajax whenever a user clicks on row of table. But due to some issue, it is always getting "alert(fail)" message.
When i replace view file with just "HI" text, it works.. but when having below mentioned form, it shows fail alert. Please help.
.JS file
$(document).ready(function(){
$('.tab tr').click(function(){
var val= $(this).attr('id');
alert(val);
$.ajax({
url: "/users/profile/",
type: "GET",
data: {'id': val},
success: function(response){
$(".tab").html(response)
},
error: function(response) {
alert('fail');
},
});
});
});
My controller method :
def profile
@prof = User.where(:id => params[:id])
respond_to do |format|
format.html {}
end
Method's view:
<%= simple_form_for(@prof, :html => {:class => 'form-vertical'}) do |f| %>
<%= f.error_notification %>
<%= f.first_name %>
<%end%>
$(".tab").html(response)and in controller method .. respond_to do |format| format.html {} format.js{} end