View Single Post
Old 04-27-2015, 03:18 PM   #1
BenTrafford
Junior Member
BenTrafford began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Jul 2006
Location: Waterloo, Ontario, Canada
Loading external file via Ajax.

Hi!

I'm trying to load an external file into my ebook via an Ajax call. The file is local to the EPUB document. However, it's not working -- does Calibre support this?

Here's the code I'm using:

Code:
$.ajax({
	async: false,
	url: theExternalDocument,
	dataType: 'xml',
	success: function(data) {
		var xmlData = new XMLSerializer();
		var strungData = xmlData.serializeToString(data);
		var fixedData = strungData.replace(/\<(\?xml|(\!DOCTYPE[^\>\[]+(\[[^\]]+)?))+[^>]+\>/g, '');
		documents[b] = new Array();
		documents[b]['contents'] = $("body", $("<div>" + fixedData + "</div>")).html();
		documents[b]['url'] = uniqueReferences[index];
	}
});
It's working in iBooks, Readium, etc., but pretty much dies in Calibre.
BenTrafford is offline   Reply With Quote