0

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)
2
  • Works fine here. Commented Jan 21, 2012 at 20:52
  • @shesek: jsfiddle.net also supports CS now, look under "Panels" in the sidebar. Commented Jan 22, 2012 at 0:46

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

4 Comments

So, in other words, you've been missing tabs and spaces. Don't do that. Set your editor to use "soft tabs" so that when you press Tab, you actually get spaces.
Wow. This one was freaking irritating as heck! Thanks for the tip. Yay for Sublime Text "Convert indentation to spaces"!
I thank you for helping me finally letting myself to go to bed soon, I have been fighting with a similar issue for more than the past half hour - blaming myself that I don't understand how to properly translate javascript to cofeescript. The fact that you sound greek as well makes this story even cooler. Efharisto! :)
given that tabs and spaces look identical in the editor but don't work the same i've since long come to look upon identation-based languages that allow to mix spaces and tabs as flawed—coffeescript and python should loudly complain when given a file that contains a mixture of spaces and tabs.
1

Your excerpt compiles fine while using the online-compiler at http://coffeescript.org/

1 Comment

...probably because in the process of copying spaces and tabs got unified.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.