我總是和麻煩, 我加載一個文件,AJAX:得到所有圖像的HTML字符串
$.ajax({
url: fullHref,
success : function(result) {
console.log(fullHref+" was loaded via AJAX");
saveImages(result);
}
});
,並試圖通過各種圖像result
迭代:
function saveImages(file){
console.log("savesImages enterd");
$(file).find('img').each(function(){
console.log("The file has this image : "+$(this).attr('src'));
});
}
}
我也試過:
$('img',file)
$('img',$(file))
$('img',$(file).html())
然而,它不會進入循環。
有什麼建議嗎? 我使用的是Chrome,而我不是想使用正則表達式。
對不起忘了複製函數聲明 –
你確定'file'包含(有效的)HTML嗎? –
您是否從AJAX調用中獲得預期的字符串? –