0
我看到了Rails指南這個片段:「ajax:success」中的冒號在JavaScript中沒有寫入對象時意味着什麼?
$(document).ready ->
$("#new_post").on("ajax:success", (e, data, status, xhr) ->
$("#new_post").append xhr.responseText
).bind "ajax:error", (e, xhr, status, error) ->
$("#new_post").append "<p>ERROR</p>"
我知道在JS,例如對象文字語法{ a: b }
但我在這裏沒有看到任何括號。結腸是什麼意思?它是一個事件的名稱,它恰好是一個冒號嗎?
段從http://guides.rubyonrails.org/working_with_javascript_in_rails.html ,第3.1節
似乎是在CoffeeScript中 - 「Rails默認帶有CoffeeScript,因此本指南中的其餘示例將在CoffeeScript中使用。」#: – danronmoon
''''''''是**字符串**並且通常在JavaScript中沒有任何具體含義(除了「嚴格使用」;')。 –