gpt4 book ai didi

javascript - 仅在点击按钮后显示 Google 客户评论

转载 作者:行者123 更新时间:2023-11-30 14:58:05 25 4
gpt4 key购买 nike

我正在使用 Google 的客户评论。它工作正常。但我的目标是,只有在我点击带有 id="google-review"

的按钮后才会加载自动覆盖

原代码为:

    <script src="https://apis.google.com/js/platform.js?onload=renderOptIn" async defer></script>
<script>
window.renderOptIn = function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render(
{
"merchant_id": number,
"order_id": order_id,
"email": customer_email,
"delivery_country": delivery_country,
"estimated_delivery_date": estimated_delivery_date,
"opt_in_style": "BOTTOM_TRAY"
});
});
}
</script>

我试过:

    $("#google-review").click(function() {
window.renderOptIn = function () {
window.gapi.load('surveyoptin', function () {
window.gapi.surveyoptin.render(
{
"merchant_id": number,
"order_id": order_id,
"email": customer_email,
"delivery_country": delivery_country,
"estimated_delivery_date": estimated_delivery_date,
"opt_in_style": "BOTTOM_TRAY"
});
});
}
});

但这行不通。叠加层根本没有加载。我怎样才能实现我的目标?

最佳答案

试试反过来。脚本源加载调用 renderOptin。然后设置一个点击处理程序。实际点击执行函数内的代码:

window.renderOptIn = function() {
$("#google-review").click(function() {
window.gapi.load('surveyoptin', function() {
window.gapi.surveyoptin.render({
"merchant_id": number,
"order_id": order_id,
"email": customer_email,
"delivery_country": delivery_country,
"estimated_delivery_date": estimated_delivery_date,
"opt_in_style": "BOTTOM_TRAY"
});
});
});
}

关于javascript - 仅在点击按钮后显示 Google 客户评论,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46942540/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com