首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >STRIPE.JS错误

STRIPE.JS错误
EN

Stack Overflow用户
提问于 2016-05-05 11:18:07
回答 1查看 168关注 0票数 0

Stripe.js试图在一个项目中实现Stripe,而我一直收到这个错误--知道我应该做什么吗?

$/ Stripe未定义、修复或添加/全局

代码语言:javascript
复制
 $(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(); 
  }
});
EN

回答 1

Stack Overflow用户

发布于 2016-05-05 11:36:33

我认为你的第一个错误来自于你使用的链接器。您可以添加/* global Stripe */作为第一行(取决于您使用的链接器)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37049235

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档