I posted question recentry as same how to use local or instance variable inruby codein coffeescript in haml templ
Getting helpful comment, I'm trying to pass param to controller in ajax but it always returns error callback I can't not find the reason.
Here is my code.
.html.haml
:coffee
$('input#field').change ->
$.ajax
url: '/posts/gaga'
type: "GET"
dataType: "json"
data: { code: $('input#field').val() }
error: (jqXHR, textStatus, errorThrown) ->
alert "error"
success: (data, textStatus, jqXHR) ->
alert "success"
routes.rb
get 'posts/gaga'
posts_controller.rb
def gaga
@model = Model.new
render nothing: true
end
Does anyone know what's wrong my code?
Thanks in advance.