您应该查看文档,了解您要做的事情:
$.post
$.ajax
就像在一篇评论中所说的,你们在这里看到的是不同语法的混合,这两种语法都是无效的。
在大多数情况下,它看起来像
$.ajax
签名,所以您可以这样稍微更改它(注意,我还修复了缩进-当您在问题中发布代码时,请尝试正确使用它,因为它对于coffeescript之类的语言很重要):
# Note i'm using string interpolation, not concatenation
$.ajax "/articles/#{id}/comments",
# add this key-val to determine the request type
method: "POST"
contentType: 'application/json'
data: comment_params:
commenter: commenter
body: body
success: (data, textStatus, jQxhr) ->
console.log(textStatus)
$('#comments').append JSON.stringify(data)
dataType: 'json'