Recaptcha 不会使用 sfFormExtraPlugin 和 JQuery Dialog (lightbox) 进行渲染
早晨。我有一个在 jquery 对话框(lightbox)内部呈现的表单,目前正在尝试将 recaptcha 实现为表单的一部分。因为我使用的是 symfony 框架,所以我可以使用包含 recaptcha 小部件的 sfFormExtraPlugin。如果我将 echo 作为原始页面的一部分,此小部件会呈现良好,但在 jquery 对话框内时不会呈现。
经过一番调查,我发现 recaptcha 创建的脚本看起来类似于以下内容:
var RecaptchaState = {
site : '6Let7r0SAAAAAJFp77tW4gRze7r5y89Cql_msPcm',
challenge : '03AHJ_VusnO7jeI3VF-cHgOIv9RY9RIpYl2QWea_LULIdL8xrM9PZdcZZ7I9gFf4gSbr1fxGCSQjQZPJQ1sa6p1oEI9U_nkU8f2SjczxjH6nzmy43Q-m_8rnxWhhRUIDa7iTPEwo4-dwi-FipyMHsSAz-nE5yfFQfZog',
is_incorrect : false,
programming_error : '',
error_message : '',
server : 'http://www.google.com/recaptcha/api/',
timeout : 18000
};
document.write('<scr'+'ipt type="text/javascript" s'+'rc="' + RecaptchaState.server + 'js/recaptcha.js"></scr'+'ipt>');
我认为问题在于 document.write,b/c 在 jquery 对话框与实际文档中调用 javascript,因此 document.write不会按预期工作。
想法?
-- 编辑 --
在我的 上发布最终解决方案博客,我本来会在这里发布,但它相当复杂。
Morning. I have a form which is rendered inside of a jquery dialog box (lightbox) and currently trying to implement recaptcha as part of the form. Because I am using the symfony framework I am able to use the sfFormExtraPlugin which includes a recaptcha widget. This widget renders fine if I echo as part of the original page, but it will not render when inside the jquery dialog box.
After some investigating, I found the script that recaptcha creates looks similar to the following:
var RecaptchaState = {
site : '6Let7r0SAAAAAJFp77tW4gRze7r5y89Cql_msPcm',
challenge : '03AHJ_VusnO7jeI3VF-cHgOIv9RY9RIpYl2QWea_LULIdL8xrM9PZdcZZ7I9gFf4gSbr1fxGCSQjQZPJQ1sa6p1oEI9U_nkU8f2SjczxjH6nzmy43Q-m_8rnxWhhRUIDa7iTPEwo4-dwi-FipyMHsSAz-nE5yfFQfZog',
is_incorrect : false,
programming_error : '',
error_message : '',
server : 'http://www.google.com/recaptcha/api/',
timeout : 18000
};
document.write('<scr'+'ipt type="text/javascript" s'+'rc="' + RecaptchaState.server + 'js/recaptcha.js"></scr'+'ipt>');
I think the problem is the document.write, b/c the javascript is being invoked within the jquery dialog box vs the actual document, so the document.write won't work as expected.
Thoughts?
-- Edit --
Posted final solution on my blog, I would have posted here but it is fairly involved.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如OP编辑中提到的,我终于找到了一个解决方案。
As mentioned in the edit of the OP, I was able to finally figure out a solution.