views:

229

answers:

1

I tried the following to respond to AJAX and it works (in HAML):

  - response.content_type = "application/json"
  = render :text => array_data.to_json

but

  - response.content_type = "application/json"
  = render :json => array_data.to_json

doesn't work. I thought I could use

  = render :text => array_data.to_json

instead of the first 2 lines at the top?

+2  A: 
= render :json => @object 

(u don't need to use .to_json method)

retro
it is actually an array... i tried and it didn't work...
動靜能量
What is not working ? Post some error message or data.inspect, etc..
retro
I also tried `= render :json => {:data => arrayData}` and see that in Firebug, the Response data portion is empty as well.
動靜能量
@retro, both cases, the Firebug shows an empty respond data portion. Response header say `Content-length` is 1
動靜能量
Why you're rendering your json in view ?
retro
Because there is a partial that return a single entry, and I need to loop through an array and concat the partial results to form 1 column, and loop 3 times to get 3 columns, and return it as a JSON data for Ajax
動靜能量