我有这个代码功能,我试图获取一个 html 并在 msg 中收到的 html 中附加一个 li 但不工作
function handleFileSelect(evt)
{
var files = evt.target.files;
$('#visor_zone').fadeOut(600);
$('#visor_zone').empty();
$.ajax(
{
url: '/home/visor_publicacion',
}).done(function(msg)
{
var html=msg;
for (var i = 0, f; f = files[i]; i++)
{
if (!f.type.match('image.*'))
{
continue;
}
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
var li = document.createElement('li');
li.innerHTML = ['<li><a><img ref="', e.target.result,'" src="', e.target.result,'"/></a><span>esta es la foto agregada</span></li>'].join('');
//li.innerHTML = ['Nombre: ', escape(theFile.name), ' || Tamanio: ', escape(theFile.size), ' bytes || type: ', escape(theFile.type), '<br /><img class="thumb" src="', e.target.result,'" title="', escape(theFile.name), '"/><br />'].join('');
html.getElementById('pikame').appendChild(li);
};
})(f);
reader.readAsDataURL(f);
}
$('#visor_zone').fadeIn(600,function()
{
$('#visor_zone').html(html);
$("#pikame").PikaChoose({autoPlay:false});
});
});
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);
它不起作用,但接下来的工作为什么是那些之间的区别
function handleFileSelect(evt)
{
var files = evt.target.files;
$('#visor_zone').fadeOut(600);
$('#visor_zone').empty();
$.ajax(
{
url: '/home/visor_publicacion',
}).done(function(msg)
{
$('#visor_zone').html(msg);
for (var i = 0, f; f = files[i]; i++)
{
if (!f.type.match('image.*'))
{
continue;
}
var reader = new FileReader();
reader.onload = (function(theFile) {
return function(e) {
var li = document.createElement('li');
li.innerHTML = ['<li><a><img ref="', e.target.result,'" src="', e.target.result,'"/></a><span>esta es la foto agregada</span></li>'].join('');
//li.innerHTML = ['Nombre: ', escape(theFile.name), ' || Tamanio: ', escape(theFile.size), ' bytes || type: ', escape(theFile.type), '<br /><img class="thumb" src="', e.target.result,'" title="', escape(theFile.name), '"/><br />'].join('');
document.getElementById('pikame').appendChild(li);
};
})(f);
reader.readAsDataURL(f);
}
$('#visor_zone').fadeIn(600,function()
{
$("#pikame").PikaChoose({autoPlay:false});
});
});
}
document.getElementById('files').addEventListener('change', handleFileSelect, false);