开发者

$.ajax will not work with coffeescript

I have the following code which I am try to write with coffeescript.

$.ajax {
  type: 'GET'
  url: '/dashboard'
  success: (response) -> 
    $('.loading_row').remove()
  dataType: 'script'
}

Every time I try to run this get the following error message:

Assertion failed: (0 && "implement me"), function uv_fs_readlink, file src/unix/fs.c, line 613.

I can solve this by putting the success callback all on one line but I wish to call multiple methods in the callback so this will not work.

$.ajax {
  type: 'GET'
  url: '/dashboard'
  success: (response) -> 开发者_如何学Go$('.loading_row').remove()
  dataType: 'script'
}


It can't be the case that you're getting different results depending on whether the success callback is defined on one line or indented. Both the code snippets you give compile to the exact same JavaScript, byte for byte:

$.ajax({
  type: 'GET',
  url: '/dashboard',
  success: function(response) {
    return $('.loading_row').remove();
  },
  dataType: 'script'
});

Unless perhaps you're using an older version of CoffeeScript? The latest release is 1.1.2.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜