Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET an SVG file as a string from JavaScript

    $.get('/vectorimage.svg', function(svg){

        //returns undefined
        console.log(svg.getElementsByTagName('svg')[0].innerHTML);

        //returns undefined
        console.log(svg.documentElement.innerHTML);

        //returns document
        console.log(svg);
    });

I want to get the response as a string plain and simple.

like image 824
Fresheyeball Avatar asked Jan 15 '12 00:01

Fresheyeball


1 Answers

$.get('/vectorimage.svg', function(svg){
    console.log( svg );
}, 'text');
like image 146
Fresheyeball Avatar answered Oct 09 '22 20:10

Fresheyeball