我正在构建一个 ASP.NET MCV 应用程序,并且我有一个用户可以在其中进行搜索的页面。我正在使用 Ajax 来获取结果。这是我的页面结构(简化):
// The part of my page that does not change
<div id = "searchForm">
<input id="txWhat" type="text"/>
<input id="txWhere" type="text"/>
<input id="idBnSearch" type="submit" value="Search"/>
</div>
// The result container
<div "resultContainer">
// Here is where I put the result, and the captcha
</div>
我想做的是每 20 次搜索操作添加一个 reCaptcha。因此,我添加了一个包含验证码的部分 View ,其想法是,当搜索操作数达到 20 时,我显示验证码部分 View ,如果 reCaptcha 输入正确,则获得输入的结果标准。
问题是,因为我使用的是 Ajax,所以无法加载验证码(没有要输入的文本)。有什么想法吗?
提前致谢
最佳答案
我假设您熟悉 jquery AJAX。
$.ajax(function(){
beforeSend: function(){
Recaptcha.create("YOUR_KEY", 'captchadiv', {
tabindex: 1,
theme: "clean",
callback: Recaptcha.focus_response_field
});
}
})
关于jquery - 使用 Ajax 时 reCaptcha 不会重新加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18126763/