Edit in JSFiddle

function setBase64Image(object, img_id) {
    if ( object.files && object.files[0] ) {
        var FR = new FileReader();
        FR.onload = function(e) {

             $(img_id).attr("src", e.target.result);
        };       
        FR.readAsDataURL( object.files[0] );
    }
}

 function upload_user_img(inputObject)
  {
  alert($('body').html());
    setBase64Image(inputObject, '#img');
  }
<input  type="file" id="user_img_input" onchange="upload_user_img(this);" /> 
<img src="" id="img" />