[英]Stripe checkout button on dynamic/Ajax page
I've integrated the Stripe checkout button with script tag inside a form, according to the standard example . 根据标准示例 ,我在表单中集成了Stripe checkout按钮和脚本标记。 It works if the content is output as a new HTML page, but if the content is introduced dynamically (via Ajax and innerHTML), the button isn't shown.
如果内容作为新的HTML页面输出,它可以工作,但如果内容是动态引入的(通过Ajax和innerHTML),则不显示该按钮。 How can I trigger it manually?
如何手动触发?
Two ways I can think of, the first, and I'd say the best way, is don't use the Standard Example, but instead use Stripe's Custom Example . 我能想到的两种方式,第一种,我说最好的方法,是不使用标准示例,而是使用Stripe的自定义示例 。 Then you can just call
handler.open({...})
. 然后你可以调用
handler.open({...})
。
Or, if you must use the inline script, I forced the button's click event using jQuery. 或者,如果必须使用内联脚本,我使用jQuery强制按钮的单击事件。
$(".stripe-button-el").click();
But I don't recommend this because not all browsers are going to support it for security reasons. 但我不建议这样做,因为并非所有浏览器都会出于安全原因支持它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.