我正在尝试调用handleResponse函数,并声明它未定义。我似乎无法弄清楚它们在同一个$ document.ready函数中。
jQuery ->
handleResponse(response) ->
if (response.status_code == 201)
fundingInstrument = response.cards != null ? response.cards[0]
jQuery.post("models/Tablecharge",
uri : fundingInstrument.href,
(r) ->
if (r.status == 201)
redirect_to @table
else
render 'new'
)
$('#cc-submit').click (e) ->
e.preventDefault()
payload =
name: $('#cc-name').val()
number: $('#cc-number').val(),
expiration_month: $('#cc-ex-month').val(),
expiration_year: $('#cc-ex-year').val(),
cvv: $('#ex-cvv').val(),
balanced.card.create(payload, handleResponse())
答案 0 :(得分:1)
你需要
balanced.card.create(payload, handleResponse)
而不是
balanced.card.create(payload, handleResponse())