Hey there, I'm new to Coffeescript and have a question regarding Ajax.
jQuery ->
api =
getId: ->
res = []
$.ajax
dataType: "jsonp"
url: "http://localhost:3004/videos.json"
success: (data) =>
if data
data.forEach (elem) =>
embed_id = elem.video_id
res.push(embed_id)
console.log res
return res
I tried running this code, and then
console.log res
The output I get is
["id1","id2","id3",...] .
I am hoping that api.getId()
would return ["id1","id2","id3",...]
However, what I see instead is
Object
-> abort
function(a) {...}
...
-> status: 200
...
-> success: function (){...}
appearing in my debug window.
I really want to retrieve the value of the response.