0
我試圖用js和ASP.NET MVC3剃刀更新驗證碼。我發現這個解決方案: 查看:jquery update captcha
<div id ="CaptchaDiv"> <img alt="Captcha" id="Captchaimg" src="@Url.Action("GetCaptcha")" style="" /></div> <input type="button" value="Refresh" onclick=" return GetCaptcha()" />
控制器:
public ActionResult GetCaptcha()
{
FileContentResult img = null;
int res = 0;
MemoryStream mem = Metods.CaptchaImage(out res);
Session["Captcha"] = res;
img = this.File(mem.GetBuffer(), "image/Jpeg");
return img;
}
JS:
function GetCaptcha()
{
$('Captchaimg').attr('src', '/Account/GetCaptcha?' + new Date().getTime());
}
不過:這是行不通的。 JS成功運行。但控制器操作不會運行。哪裏不對?有任何想法嗎?
謝謝,我的注意力會在某個時候殺死我 – Yury 2013-02-28 11:45:42