CoffeeScript 与 jquery ajax
$.ajax '/',
type: 'GET'
dataType: 'html' error: (jqXHR, textStatus, errorThrown) ->
$('body').append "AJAX Error: #{textStatus}"
success: (data, textStatus, jqXHR) ->
$('body').append "Successful AJAX call: #{data}"
上面的代码有问题,无法编译成js
$.ajax '/',
type: 'GET'
dataType: 'html' error: (jqXHR, textStatus, errorThrown) ->
$('body').append "AJAX Error: #{textStatus}"
success: (data, textStatus, jqXHR) ->
$('body').append "Successful AJAX call: #{data}"
there is something wrong with the above code,I can't compile it into js
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误
编译器给出引用该行的
The 问题很简单,在
'html'
和error
之间没有逗号(或换行符)。这是固定代码:我强烈建议使用带有内置“构建”命令的编辑器,尤其是可以处理选定文本的编辑器。它使语法错误更容易被发现。
The compiler gives the error
referring to the line
The problem is simply that there's no comma (or line break) between
'html'
anderror
. Here's the fixed code:I highly recommend using an editor with a built-in "Build" command, especially one that can work on selected text. It makes syntax errors a lot easier to pin down.