开发者

$.ajax will not work with coffeescript

开发者 https://www.devze.com 2023-04-01 17:56 出处:网络
I have the following code which I am try to write with coffeescript. $.ajax { type: \'GET\' url: \'/dashboard\'

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

精彩评论

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