Shopify 未执行 jQuery(地理位置脚本)

Shopify not executing jQuery (Geolocation script)

我正在尝试使用 jQuery 脚本根据用户的位置更改联系人页面布局。它在 JSbin 中按预期工作,但是当移植到 Shopify 时它根本无法工作。

控制台中没有任何内容表明存在冲突。

有没有人知道为什么它不起作用?

编辑:将代码片段更新为工作解决方案。被调用的 IP 服务不允许 HTTPS 请求,我切换到另一个服务,现在它正在按预期在 Shopify 上运行。

<script>
    $(document).ready(function() {
      
    $.ajax({
      url: "https://freegeoip.app/json/",
  dataType: "jsonp",
  success: function(json) {
    if (json.country_code === "GB") {
        alert('you are in the UK'); 
  }
  }      
});
    });
  </script>

根据评论中提供的点赞和信息,我能够 运行 您网站上下文中的代码。代码执行成功,但您的 API 提供商禁止您根据订阅级别尝试执行的操作。查看下面的错误。

API docs 的说法有点不同 - The current subscription plan does not support this API endpoint.