Reputation: 345
I have been following an excellent tutorial for creating a shopping cart in node.js
But I have hit a snag, and I have read and re-read the code and can't see what I have done wrong.
Basically I have an hbs
file called: checkout.hbs
and at the bottom of the page I have these 2 entries:
<script type="/text/javascript" src="javascripts/checkout.js"></script>
<script type="/text/javascript" src="https://js.stripe.com/v2/"></script>
I have a public folder in my project with a javascripts folder and a checkout.js
file in there.
However when I click the submit button it seems to ignore the javascript file and go straight to the post. I tried putting some random code in the checkout.js
file to see if it crashed, but it didn't which suggests its not even trying to use the script and I am not sure why.
checkout.hbs - should get checkout-form using id in checkout.js
<form action="/checkout" method="post" id="checkout-form">
checkout.js
var $form = $('#checkout-form');
$form.submit(function (event) {
Upvotes: 0
Views: 1232
Reputation: 345
I needed to change:
<script type="/text/javascript" src="javascripts/checkout.js"></script>
to:
<script src="javascripts/checkout.js"></script>
Upvotes: 1
Reputation: 4728
EDIT:
<script type="/text/javascript"
should be
<script type="text/javascript"
OLD VERSION:
try not using the protocol to links (even outside of your site)
https://js.stripe.com/v2/
can be written as
//js.stripe.com/v2/
and the browser will use the same protocol for the link as the one in the browser's address bar
Upvotes: 0