【发布时间】:2012-11-25 03:10:06
【问题描述】:
我正在使用https://github.com/augustl/js-epub 解析 .epub 文件。但我收到错误为“XML 解析错误:未找到元素”。我在第 3 步之前没有问题,它在后处理步骤中失败。我是使用以下代码
$(document).ready(function(){
$('#something').html('fetching');
$.ajax({
url: "alice.epub",
complete: function(response, status, request) {
var the_zip = new JSUnzip(response.responseText);
$('#something').html('finished with ' + status);
console.log("is it zip?" + the_zip.isZipFile());
var epub = new JSEpub(response.responseText);
epub.processInSteps(function (step, extras) {
var msg = '';
console.log(step);
if (step === 1) {
msg = "Unzipping";
} else if (step === 2) {
msg = "Uncompressing " + extras;
}
else if (step === 3) {
msg = "Reading OPS";
}
else if (step === 4) {
msg = "Post processing";
alert(msg);
}
else if (step === 5) {
msg = "Finishing";
alert('done!');
}
else {
msg = "Error!";
}
$('#something').html(msg);
});
}
});
});
谁能告诉我上面代码中的错误。
【问题讨论】:
-
您是否尝试过 js-epub 页面上给出的 Base64 编码 XHTTP 传输的建议?
-
我尝试了您的建议,但在 js-unzip.js 中出现错误,并且在 step1 本身中失败。
-
听起来你在处理之前没有从 Base64 解码
-
我使用了 github.com/carlo/jquery-base64 链接中的 base64.js,但它没有解码数据,您可以建议我任何其他链接。
标签: javascript epub