简体   繁体   中英

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 . 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. 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 . Then you can just call handler.open({...}) .

Or, if you must use the inline script, I forced the button's click event using jQuery.

$(".stripe-button-el").click();

But I don't recommend this because not all browsers are going to support it for security reasons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM