Coffeescript / JQuery / Rails:$ .ajax

编程入门 行业动态 更新时间:2024-10-28 03:30:04
Coffeescript / JQuery / Rails:$ .ajax - 解析错误,意外'{'(Coffeescript/JQuery/Rails: $.ajax - Parse error, unexpected '{')

我现在已经设法在很长一段时间内完成了一个简单的解析器错误。 我在网上找到了几个代码示例,这些代码看起来很相似 - 我非常感谢一个提示!

$ -> $(".category_modal").click (e) -> alert "Hi" e.preventDefault() $.ajax url: 'entries/detail' type: "GET" <-- Error: Parse error on line 28: Unexpected '{' dataType: 'json' success: (data) -> alert "Hi again" $(".category_modal").html(data)

I don't manage to get past a simple parser error for quite some time now. I found several code sample on the web and those seem to be similar - I would deeply appreciate a hint!

$ -> $(".category_modal").click (e) -> alert "Hi" e.preventDefault() $.ajax url: 'entries/detail' type: "GET" <-- Error: Parse error on line 28: Unexpected '{' dataType: 'json' success: (data) -> alert "Hi again" $(".category_modal").html(data)

最满意答案

根据您使用的IDE,我发现由于格式错误的空格,我经常会收到编译Coffescript文件的错误。

解决方案:选择'type:'之前的所有空格和前一行末尾的空格,即:'tries / detail'之后

删除它们,然后重新形成它们并再次尝试编译。 特别是当我从其他来源复制粘贴时,会发生这种情况

Depending on the IDE you use, I have found out that oftentimes I get errors compiling Coffescript files due to malformed spaces.

Solution: Select all the spaces before 'type:' AND the ones on the end of the previous line, ie after: 'tries/detail'

Delete them, and form them again and try again to compile. This happens especially when I copy-paste from other sources

更多推荐

本文发布于:2023-04-29 08:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335994.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JQuery   Coffeescript   ajax   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!