jquery - Load external SVG file into variable and append to html -



jquery - Load external SVG file into variable and append to html -

i'm trying replace svg image embedded in img tag content of svg , output inline. in other words lo load contents of svg file of given img src attribute variable , inject inline svg html, this:

...

else if (type && type === 'img-simple') { if (format === 'svg' ) { $.get(src, function(data) { var svg = $(data); $bg.append(svg); });

} else {

...

where var type image class , format image type: jpg, sag etc.

which gives me next error:

[error] failed load resource: origin null not allowed access-control-allow-origin. (img01.svg, line 0) [error] xmlhttprequest cannot load file:///users/img01.svg. origin null not allowed access-control-allow-origin. (index.html, line 0)

apparently it's function problem?

thanks in advance

you cannot load info via ajax using file:// protocol. need utilize http://

for example, move svg file same folder javascript file , do:

$.get('img01.svg', function(data) { $bg.append(data); });

jquery svg

Comments