Code below. 20 svg-elements within a XML-document got from a server via asynchrounous XMLHttpRequest, put into the table svgs (svgs.length == 20, OK). I'd like to put one randomly selected svg-element from the table to html5-page as a inline code. So I think I would need to have single svg -element as a string, which could be inserted to the html5-page. How to do this? And yes, I know that with innerHTML or with jQuery's .load()-method, but what I should the give as a parameter?
Code:
function showImage() {
if(xhr.readyState == 4){
if(xhr.status == 200){
if(xhr.responseXML && xhr.responseXML.childNodes.length > 0){
res = xhr.responseXML;
svgs = res.getElementsByTagName("svg");
alert(svgs.length);
}else{
document.getElementById('container').innerHTML = xhr.responseText;
}
}else{
$('#container').load(toText(xhr.status));
}
}
}