我有一个action方法返回一个图像文件captcha,我不知道如何实现一个按钮来刷新这个captcha。我想我应该使用Jquery,因为我不希望这个页面重新加载,但是我不知道如何实现它。
这是我的操作方法:
public ActionResult Index()
{
var captcha = new DemoMVC2112.Models.CenterCaptcha();
Session["captcha"] = captcha.Text;
return File(captcha.ImageAsByteArray, "image/png");
}Div at View:
<div class="captchaImage">
<img src='@Url.Action("Index", "CaptchaImage")' id="captchaImage" /> <button id="Refresh_Captcha">ReFresh CaptCha</button>
</div>

发布于 2020-01-15 06:33:17
尝试像这样添加,我希望这能解决你的问题
然后通过添加日期来刷新captcha的内容来绑定captcha。
function reloadCaptcha()
{
document.getElementById('captchaImage').src =
document.getElementById('captchaIMage').src+ '?' new Date().getTime();
}https://stackoverflow.com/questions/59744813
复制相似问题