Fixed issue 698: failure to xhr load the svg reslts in an unusable svg-edit screen

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1787 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2010-10-08 18:21:46 +00:00
parent 884e92dc3a
commit d3b2f899a3
1 changed files with 19 additions and 8 deletions

View File

@ -4406,9 +4406,15 @@
var callbacks = [];
function loadSvgString(str) {
if(!svgCanvas.setSvgString(str)) {
$.alert('Error: Unable to load SVG data.');
function loadSvgString(str, callback) {
var success = svgCanvas.setSvgString(str) !== false;
callback = callback || $.noop;
if(success) {
callback(true);
} else {
$.alert('Error: Unable to load SVG data', function() {
callback(false);
});
}
}
@ -4433,18 +4439,23 @@
});
};
Editor.loadFromURL = function(url, cache) {
Editor.loadFromURL = function(url, opts) {
var cache = opts.cache;
var cb = opts.callback;
Editor.ready(function() {
$.ajax({
'url': url,
'dataType': 'text',
cache: !!cache,
success: loadSvgString,
success: function(str) {
loadSvgString(str, cb);
},
error: function(xhr, stat, err) {
if(xhr.responseText) {
loadSvgString(xhr.responseText);
if(xhr.status != 404 && xhr.responseText) {
loadSvgString(xhr.responseText, cb);
} else {
$.alert("Unable to load from URL. Error: \n"+err+'');
$.alert("Unable to load from URL. Error: \n"+err+'', cb);
}
}
});