IbrahimMitko
IbrahimMitko

Reputation: 1207

Undefined error when embedding SVG

I' using an ajax call to retrieve an htm file that builds an SVG. The call returns the file successfully but the area where it's suppose to appear simply says:

enter image description here

Is this a timing issue? I have the ajax call in a separate js file that is called after the page loads.

function buildMap(){
    var lbmp = document.getElementById("lbmp-map");
    if(lbmp != null){
        $.ajax({ 
            url:'../footer.htm',
            method: 'GET',
            success: function(response){
                lbmp.innerHTML = response.responseText;
            },
            failure: function(response){
                lbmp.innerHTML = "<p>Failure</p>";
            }
        }); 
    }
}

Upvotes: 0

Views: 210

Answers (1)

Gwendal
Gwendal

Reputation: 1273

On success, ajax gives you directly the content, so your html is in response and not in response.responseText, that's why you are getting the undefined message.

Upvotes: 1

Related Questions