Javascript 在coffeescript中检查ajax请求失败
我想使用coffeescript语法中的.post jquery方法发出post请求。coffeescript文档提供了添加成功回调的示例,但没有提供添加错误回调的语法。我该怎么做Javascript 在coffeescript中检查ajax请求失败,javascript,jquery,ajax,coffeescript,Javascript,Jquery,Ajax,Coffeescript,我想使用coffeescript语法中的.post jquery方法发出post请求。coffeescript文档提供了添加成功回调的示例,但没有提供添加错误回调的语法。我该怎么做 $.post '/', userName: 'John Doe' favoriteFlavor: 'Mint' (data) -> $('body').append "Successfully posted to the page." # Callback for error c
$.post '/',
userName: 'John Doe'
favoriteFlavor: 'Mint'
(data) -> $('body').append "Successfully posted to the page."
# Callback for error case?
或者,在方法选项中定义这两个回调会给您带来什么
$.post('/',
userName: 'John Doe'
favoriteFlavor: 'Mint'
(data) -> $('body').append "Successfully posted to the page."
).fail((data) -> "Error handler")