gpt4 book ai didi

json - reCAPTCHA JSON中位置0处的意外 token

转载 作者:行者123 更新时间:2023-12-03 15:58:37 24 4
gpt4 key购买 nike

我们使用reCAPTCHA版本2作为“我不是机器人”复选框。从2020-11-05 19:23:00Z开始,在我们的页面加载期间,我们得到了异常(exception):

recaptcha__ru.js:211 Uncaught (in promise) SyntaxError: Unexpected token   in JSON at position 0
at JSON.parse (<anonymous>)
at recaptcha__ru.js:211
at recaptcha__ru.js:209
at Array.<anonymous> (recaptcha__ru.js:132)
at Array.<anonymous> (recaptcha__ru.js:208)
at GM.$ (recaptcha__ru.js:211)
at Array.<anonymous> (recaptcha__ru.js:253)
at QS.next (recaptcha__ru.js:416)
at y (recaptcha__ru.js:355)
https://www.google.com/recaptcha/api2/anchor?ar=1&k=6LcOyt8ZAAAAAD9WJMwwwvgvSGp8Bi0zWYS-FMX5&co=aHR0cDovL2JsYWNrYmlyZDo0ODA4MA..&hl=ru&v=1AZgzF1o3OlP73CVr69UmL65&size=normal&cb=a79dhaz0etu中发生异常
enter image description here
我们的页面未更改。 reCAPTCHA在一瞬间意外中断。在其他页面上,reCAPTCHA仍在工作(可能重要的是,工作页面已嵌入到iframe中)。
有什么提示吗?什么地方出了错?
更新了
我们尝试在JSP页面中的iframe中隔离reCAPTCHA,如 @user2384519建议:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Captcha test</title>
<script>
function extractRecaptchaResponse() {
var c = document.getElementById('g-recaptcha-isolator');
if (c) {
var src = c.contentWindow.document
.getElementById('g-recaptcha-response');
if (src) {
var target = document.getElementById('g-recaptcha-response');
target.value = src.value;
}
}
return true;
}
</script>
</head>
<body>
<h:form id="g-recaptcha-form">

<h:panelGroup>
<iframe id="g-recaptcha-isolator" src="/recaptcha.htm"
onload='javascript:(function(o){o.style.height=o.contentWindow.document.body.scrollHeight+"px";}(this));'
style="height: 78px; width: 100%; border: none; overflow: hidden;">
</iframe>
</h:panelGroup>

<textarea id="g-recaptcha-response" name="g-recaptcha-response"
style="display: none"></textarea>

<h:panelGroup>

<h:commandLink onclick="extractRecaptchaResponse()"
actionListener="#{recaptcha.submit}">
<span>Submit</span>
</h:commandLink>

</h:panelGroup>

</h:form>
</body>
</html>
recaptcha.htm:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<script src="https://www.google.com/recaptcha/api.js"></script>
</head>
<body>
<div class="g-recaptcha" data-sitekey="xxxxxxx"></div>
并解决了JSON错误的问题,但是reCAPTCHA使用图片选择器显示了弹出窗口,而iframe则删除了弹出窗口。

最佳答案

如果您使用的是Prototype.js:
Prototype JS库重写了reduce类中的Array方法。
如果您在所有导入之后添加以下脚本(最好在body标签之后),则可以解决此问题:

Array.prototype.reduce = function(callback, initialVal) {
var accumulator = (initialVal === undefined) ? undefined : initialVal;
for (var i = 0; i < this.length; i++) {
if (accumulator !== undefined)
accumulator = callback.call(undefined, accumulator, this[i], i, this);
else
accumulator = this[i];
}
return accumulator;
};

关于json - reCAPTCHA JSON中位置0处的意外 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64737646/

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