Get an image through jQuery AJAX

后端 未结 2 570
逝去的感伤
逝去的感伤 2020-12-20 14:49

The following image tag is in my Login Page

\"Captcha\"


        
相关标签:
2条回答
  • 2020-12-20 15:37

    web Server should return base64 Data. like this

    { base64Data:"blahblahblah" }
    

    your ajax request content-type could be plain json ; in your success function in ajax you could do like this

        success:function(data){
         var src="data:image/png;base64,"+data.base64Data;
          $('#CaptchaImg').attr(src,src)
    }
    
    0 讨论(0)
  • 2020-12-20 15:46

    Try this

    $.ajax({
        type: "GET",
        url: '@Url.Action("Captcha","Login")',
        dataType:"image/jpg",
        success: function (data) {
            $('#CaptchaImg').attr('src', data);
        }
     });
    
    0 讨论(0)
提交回复
热议问题