仍然让我对CoffeeScript感兴趣,并看到它的功能。返回Coffeescript中的Ajax请求的结果
我写了一个方法,使ajax调用,我想要返回结果。
例如:
GetViewedItem: (foo) ->
$.ajax '/Foo/Bar/',
type: 'GET',
data: { id: $(foo).data('fooId') }
success: (data) ->
data
,我想返回数据。有没有在CoffeeScript中做到这一点的巧妙方法,还是我只需要声明一个变量?
谢谢
你是否意味着“转向”异步到同步? http://stackoverflow.com/questions/6406100/how-does-coffeescript-handle-asynchronous-calls – tokland 2012-02-06 17:14:12