正方形pos卡支付表单集成在ajax中(square pos card payment form integration in ajax)

编程入门 行业动态 更新时间:2024-10-27 04:33:37
正方形pos卡支付表单集成在ajax中(square pos card payment form integration in ajax)

我是新来的方形支付表单集成。 我正在根据https://docs.connect.squareup.com/articles/adding-payment-form.when上的文档整合表单,当我将表单嵌入到单个页面时,它工作正常,但是当我加载表单时脚本在ajax中显示错误“ReferenceError:SqPaymentForm未定义”。 有人请告诉我一种将表单嵌入ajax的方法。

I am new to square payment form integration. i am integrating the form according to the documentation on https://docs.connect.squareup.com/articles/adding-payment-form .when i am embedding the form on a individual page it works fine but when i am loading the form scripts in ajax it showing the error " ReferenceError: SqPaymentForm is not defined ". some one please suggest me a way to embed the form in ajax.

最满意答案

这里的问题是,你可能试图在页面上运行JavaScript(它有类似var paymentForm = new SqPaymentForm({...在外部库加载之前。

如果您异步加载https://js.squareup.com/v2/paymentform ,则需要延迟页面上JavaScript的执行,直到外部库加载完成。 你可以通过onload事件来做到这一点,或等待页面完全加载(或许多其他方式,搜索“在异步之后延迟javascript”),但最简单的方法是同步加载库。

The problem here is that you are likely trying to run the javascript on the page (that has something like var paymentForm = new SqPaymentForm({... before the external library has loaded.

If you are loading the https://js.squareup.com/v2/paymentform asynchronously, you'll need to delay the execution of the javascript on the page until after the external library has loaded. You can do this via onload events, or waiting until the page is fully loaded (or lots of other ways, search for "delaying javascript after async", but the easiest way would be to just load the library synchronously.

更多推荐

本文发布于:2023-07-05 02:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1032119.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:正方形   表单   ajax   square   pos

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!