Is there a way to get the epub file from a uri which download a epub file automatically using ajax request. Sample link would be http://www.bookrix.com/Books/Download.html?bookID=bx.dickens_1276691363.9406330585&format=epub. Currently Im getting the file on the server side and can show it using epubreader but I want to use the file on the client side and place it in the epubreader. I get this error when I run the ajax request. Ive tryed to change the headers with no luck. XMLHttpRequest cannot load . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
$.ajax({
type: 'GET',
url: 'http://www.bookrix.com/Books/Download.html?bookID=bx.dickens_1276691363.9406330585&format=epub',
dataType: 'application/xml',
crossDomain: true,
beforeSend: function(request) {
request.setRequestHeader('Access-Control-Allow-Origin', "*");
request.setRequestHeader('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
request.setRequestHeader('Content-Type', 'GET');
},
success: function (result) {
window.alert("success!!");
},
error: function (exception) {
window.alert("something wrong!" + exception);
}
}).error(function(data) {
console.log('Error:', data);
});
$(document).ready(function() {
$("#btnSubmit").click(function() {
alert("button");
console.log("jtest");
});
});
Iv'e implemented rack::cors with no success