There are 2 options.
The first is with a regular expression. This option will not work if in a block (for example a div) there will be nested blocks with the same tag (div).
function handleServerResponse() { var response = xmlHttp.responseText; myDiv = document.getElementById('myDivElement'); var VRegExp = new RegExp(/<div.* class="test".*>.*<\/div>/);//регулярное выражение var VResult = response.match(VRegExp);//поиск строки myDiv.innerHTML = VResult; }
The second is to simply insert everything into an invisible block (display: none), then find the necessary block through the DOM and insert the values where necessary.
The second option:
function handleServerResponse() { var response = xmlHttp.responseText; myDiv = document.getElementById('myDivElement'); myDiv.innerHTML = "<div style='display:none'>"+response+"</div>"; myDiv.innerHTML = myDiv.querySelector("pre.data").innerHTML; }