Image preview before upload in IE and Chrome

前端 未结 7 2038
说谎
说谎 2021-02-14 19:51

I am trying to design a module in which I would like to show a preview of the image to the user before he uploads the image to database.

I have found a solution which wo

7条回答
  •  梦谈多话
    2021-02-14 20:25

    Use jQuery ajax to solve your problem.

    $.ajax({
        type: "post",
        url: "serverURL?randomParam="+(Math.random() * 1000),
        cache: false,               
        data: null,
        success: function(json){
            try{            
                var obj = JSON.parse(json);                                             
                if(obj[0].IMAGE!=null){                             
                    $("#captchaImage").attr("src", obj[0].IMAGE); 
                }               
            }catch(e) {     
                showMessage("E1");  
            }
        },
        error: function(){
        }
    });
    

提交回复
热议问题