$.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
The compiler gives the error
Parse error on line 3: Unexpected 'IDENTIFIER'
referring to the line
dataType: 'html' error: (jqXHR, textStatus, errorThrown) ->
The problem is simply that there's no comma (or line break) between 'html'
and error
. Here's the fixed code:
$.ajax '/',
type: 'GET'
dataType: 'html'
error: (jqXHR, textStatus, errorThrown) ->
$('body').append "AJAX Error: #{textStatus}"
success: (data, textStatus, jqXHR) ->
$('body').append "Successful AJAX call: #{data}"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With