View Single Post
Old 02-15-2013, 11:59 AM   PM User | #1
tumpelo
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
tumpelo is an unknown quantity at this point
svg-elements in xml via XHR, putting a single element as an inline code to html5

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));
} 
}
}
tumpelo is offline   Reply With Quote