I’m running jquery from a file. And I’m trying to load a svg file from my localhost to populate a svg canvas. However that does not work as expected.
What I do from filesystem:
$.ajax({ url: url ,
timeout: 1000,
complete: function(xml) {
alert('complete');
},
success: function(xml, status, xreq) {
alert('success');
},
error: function() {
alert('error');
}
});
the url reads: http://localhost/image.svg, when I read this url directly from an addressbar from the browser, the pages remains white but the pagesource displays the source of image.svg.
Debugging the $.ajax code above, reveals that the success: method is hit, but xml response remains empty.
Any help is greatly appreciated.
regards,
jeroen.
If your webserver at localhost does not send the correct mime type for the SVG file then the .ajax call will ignore the contents. Try a vanilla XML file, then rename it to xml.nonsense and you’ll see the same effect.