Get multiple SVG file contents using javascript/ajax function -


i have multiple svg files want load asynchronously. i've written following function can call:

function getsvg(filename){   getsvg = new xmlhttprequest();   getsvg.open('get','assets/svg/'+filename+'.svg',false);   getsvg.send();   return getsvg.responsexml.documentelement; } 

now can load contents so:

var basesvg = getsvg('base'); document.getelementbyid('canvas').appendchild(basesvg); 

that works great, when try call second time doesn't work. example:

var midsvg = getsvg('mid'); document.getelementbyid('canvas').appendchild(midsvg); 

this time following error:

'uncaught typeerror: property 'getsvg' of object [object object] not function 

i'm no great expert javascript , ajax not sure about.

function getsvg(filename){       // <- create function in global namespace called getsvg   var getsvg = new xmlhttprequest(); // <- overwrite function new xmlhttprequest object   ... } 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -