Stripe.js试图在一个项目中实现Stripe,而我一直收到这个错误--知道我应该做什么吗?
$/ Stripe未定义、修复或添加/全局
$(document).ready(function() {
Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'));
// Watch for a form submission:
$("#form-submit-btn").click(function(event) {
event.preventDefault();
$('input[type=submit]').prop('disabled', true);
var error = false;
var ccNum = $('#card_number').val(),
cvcNum = $('#card_code').val(),
expMonth = $('#card_month').val(),
expYear = $('#card_year').val();
if (!error) {
// Get the Stripe token:
Stripe.createToken({
number: ccNum,
cvc: cvcNum,
exp_month: expMonth,
exp_year: expYear
}, stripeResponseHandler);
}
return false;
}); // form submission
function stripeResponseHandler(status, response) {
// Get a reference to the form:
var f = $("#new_user");
// Get the token from the response:
var token = response.id;
// Add the token to the form:
f.append('<input type="hidden" name="user[stripe_card_token]" value="' + token + '" />');
// Submit the form:
f.get(0).submit();
}
});发布于 2016-05-05 11:36:33
我认为你的第一个错误来自于你使用的链接器。您可以添加/* global Stripe */作为第一行(取决于您使用的链接器)。
https://stackoverflow.com/questions/37049235
复制相似问题