1. 程式人生 > >jquery ajax 獲取 後臺傳入base64 圖片資料轉成圖片示例

jquery ajax 獲取 後臺傳入base64 圖片資料轉成圖片示例

   $.ajax({
            type: 'POST',
            dataType: 'json',
            url: 'JsonAction',
            async: false,    
            data: {'moRadom' : random},
            success: function(json){
                
                   jsondata=$.parseJSON(json);

                    
                
                    var t=jsondata.data;
                    var divshow = $("#regshow");
                    divshow.text("");// 清空資料
                    h="<img id=\"mops\" src='data:image/jpg;base64,"+t+"' style=\"width:79px;height:30px;margin-right:-4px;\"/>";
                
                    divshow.append(h);                      
                
            },
             error:function() {
                  
                 alert("系統資料異常,請稍後再試......");
           
        }
      
        
        });