The following image tag is in my Login Page
以下图片代码位于我的登录页面中
<img id="CaptchaImg" alt="Captcha" src="@url.action("Captcha","Login")" style="" />
Now when I refresh my login Page, it works fine, and gets the image from the controller, but when I logOut and the login Page renders .the controller method is not being called.Problem is only in IE works fine on Chrome.Is there are work around? Can I do something with jQuery Ajax call to the controller, I tried this but the success method is not called. Is there any other way?
现在,当我刷新我的登录页面时,它工作正常,并从控制器获取图像,但是当我登录和登录页面渲染时,控制器方法没有被调用。问题只在IE中正常运行Chrome.Is那里正在努力?我可以用jQuery Ajax调用控制器做一些事情,我试过这个但是没有调用成功方法。还有别的办法吗?
$.ajax({
type: "GET",
url: '/Login/CaptchaImage',
datatype: "image",
success: function(data) {
debugger
$('#CaptchaImg').attr('src', data);
}
});
2 个解决方案
#1
10
Try this
尝试这个
$.ajax({
type: "GET",
url: '@Url.action("Captcha","Login")',
dataType:"image/jpg",
success: function (data) {
$('#CaptchaImg').attr('src', data);
}
});
#2
0
web Server should return base64 Data. like this
Web服务器应返回base64数据。喜欢这个
{ base64Data:"blahblahblah" }
your ajax request content-type could be plain json ; in your success function in ajax you could do like this
你的ajax请求内容类型可以是普通的json;在你在ajax的成功功能中,你可以这样做
success:function(data){
var src="data:image/png;base64,"+data.base64Data;
$('#CaptchaImg').attr(src,src)
}
#1
10
Try this
尝试这个
$.ajax({
type: "GET",
url: '@Url.action("Captcha","Login")',
dataType:"image/jpg",
success: function (data) {
$('#CaptchaImg').attr('src', data);
}
});
#2
0
web Server should return base64 Data. like this
Web服务器应返回base64数据。喜欢这个
{ base64Data:"blahblahblah" }
your ajax request content-type could be plain json ; in your success function in ajax you could do like this
你的ajax请求内容类型可以是普通的json;在你在ajax的成功功能中,你可以这样做
success:function(data){
var src="data:image/png;base64,"+data.base64Data;
$('#CaptchaImg').attr(src,src)
}