I perform an ajax call :
...
$.ajax
url: " /backoffice/expenses/rate"
type: "GET"
dataType: "json"
data:
project_id: $('#project_id').val()
code: $(this).val()
success: (result) ->
alert result
$('#expense_price').val(result)
in the controller , I am correctly receiving the js call
Started GET "/backoffice/expenses/rate?project_id=7&code=1
Processing by Backoffice::ExpensesController#rate as JSON
..
Completed 200 OK in 2004ms (Views: 0.5ms | ActiveRecord: 2.6ms)
in my controller
def partner_rate
...
@rate = "10.00"
render :json => @rate # for testing purpose only
end
and the alert result is not displayed , what am I missing here ?
thanks for your feedback .. maybe so mistake typing this post ,
however the url is fine , as the action is correctly reached ..
if I use :
render :text => @rate
then the result is displayed ..
so it's not an Ajax call issue , rather something I don't get right
with json
can I use render :json => @ rate
@rate being a String object ? I tried
render :json => {:name => "joe"} # i.e example
and the result is also received back
so what could be wrong withe render :json => "<String> ???