I am having an odd problem.
I have a chunk of javascript that I need to insert into my payment page view file.
But PHP is trying to execute it!!!?!!!
$stripescript2 = <<<JS2
<script type="text/javascript">
var $form = jQuery("#payment-form");
$form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find(".submit").prop("disabled", true);
// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler );
// Prevent the form from being submitted:
return false;
});
</script>
JS2;
$this->registerJs( $stripescript2 , \yii\web\VIEW::POS_READY);
Here is the PHP error…
PHP Notice – yii\base\ErrorException
Undefined variable: form
1. in /home/nginx/public/basic/views/checkout/checkout.php at line 101
</script>
JS1;
$this->registerJs( $stripescript1 , \yii\web\VIEW::POS_END);
$stripescript2 = <<<JS2
<script type="text/javascript">
var $form = jQuery("#payment-form");
$form.submit(function(event) { <<------------ ERROR ON THIS LINE
// Disable the submit button to prevent repeated clicks:
$form.find(".submit").prop("disabled", true);
// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler );
// Prevent the form from being submitted:
return false;
});
Thanks
-John