2012-08-10 22 views

回答

1

你是否將它包裝在document.ready函數中?它工作正常,在小提琴下面

$(function(){ // <-- short form of below - waits for dom to load before -- 
       // elements have to exist in dom before trying to bind them 
    $("#Uploadthisfile").change(function() { 
     alert('some message'); 
    }); 
}); 
已經在文檔準備啊

$(document).ready(function() { 
    $("#Uploadthisfile").change(function() { 
     alert('some message'); 
    }); 
}); 

http://jsfiddle.net/wirey00/C6RZn/

+0

它。奇怪的不能似乎使它的工作..以及它的如此簡單 – 2012-08-10 18:44:06

+0

它的工作正常在小提琴也..在控制檯內有任何錯誤? – 2012-08-10 18:46:43

+0

發現這個問題,這完全是我的愚蠢,沒有找到它之前...我忘了我加載更多的那些在一個PHP循環與完全相同的ID .. – 2012-08-10 18:49:33

0
//Upload the File and Convert into base64 string 
$('#Uploadthisfile').live('change', function() { 

var fileList = this.files; 
var file = fileList[0]; 
var r = new FileReader(); 
r.onload = function() { 
    var binimage = r.result; 
    binimage1 = binimage.replace('data:image/jpeg;base64,', ''); 
    var imag = "<img " + "src='" + 
     "data:image/jpg;base64," + binimage1 + "' style='width:100px'/>"; 
    $("#partial1").html(imag); 

}; 
r.readAsDataURL(file); 
// r.readAsBinaryString(file); 
//r.readAsDataURL(file); 
});