Ajax return not passing Data, rails
okay, I'm sure this is simple but I'm running out of hair to pull out. I'm
posting a ajax request to my controller and trying to get the response in
CoffeeScript. I tried moving to pure JS, but didn't make a difference.
the jQuery document implies that my newImage() should be newImage(data)
but if i do that i get the error data undefined. With this code i just get
undefined for my alert.
jQuery ->
$('select[data-type=scene]').change ->
i_num= $(this).attr('data-num').toString()
i_value= $(this).find(':selected').text()
request= 'new image for :'+ i_num + ': get :' + i_value + ': image'
$.post('/new_image', {request: => request}, newImage())
newImage= (new_url) ->
alert new_url
the controller is providing a response that i can see in the console, but
the ajax callback doesn't seem to grab it. the controller code is .
def new_image request= params['request'].split(':') @url=
get_thumb_url(request[3]) @img_num= request[1] reply= @img_num + '::' +
@url render json: reply, content_type: 'text/json' end
the response is
3::https://bnacreations.s3.amazonaws.com/g/thumbnails/image.jpg
any suggestions of where i'm off track?
No comments:
Post a Comment