prevent the browsing from overwriting the requestobject, before the answer is received

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1764 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent e089f15135
commit 88c0e1da1e

@ -1,47 +1,46 @@
function AllSnippets() {
var query = document.getElementsByName("former")[0].value;
var span = document.getElementsByTagName("span");
for(var x=0;x<span.length;x++) {
if (span[x].className == 'snippetLoading') {
var url = document.getElementById("url" + span[x].id);
requestSnippet(url,query);
}
}
}
function requestSnippet(url, query){
var req=createRequestObject();
req.open('get', '/xml/snippet.xml?url=' + escape(url) + '&search=' + escape(query),true);
req.onreadystatechange = function () {handleState(req)};
req.send(null);
}
function handleState(req) {
if(req.readyState != 4){
return;
}
var response = req.responseXML;
var snippetText = response.getElementsByTagName("text")[0].firstChild.data;
var urlHash = response.getElementsByTagName("urlHash")[0].firstChild.data;
var status = response.getElementsByTagName("status")[0].firstChild.data;
function AllSnippets() {
var query = document.getElementsByName("former")[0].value;
var span = document.getElementsByTagName("span");
for(var x=0;x<span.length;x++) {
if (span[x].className == 'snippetLoading') {
var url = document.getElementById("url" + span[x].id);
requestSnippet(url,query);
}
}
}
function requestSnippet(url, query){
var req=createRequestObject();
req.open('get', '/xml/snippet.xml?url=' + escape(url) + '&search=' + escape(query),false);
req.onreadystatechange = function () {handleState(req)};
req.send(null);
}
function handleState(req) {
if(req.readyState != 4){
return;
}
var response = req.responseXML;
var snippetText = response.getElementsByTagName("text")[0].firstChild.data;
var urlHash = response.getElementsByTagName("urlHash")[0].firstChild.data;
var status = response.getElementsByTagName("status")[0].firstChild.data;
var span = document.getElementById(urlHash)
removeAllChildren(span);
removeAllChildren(span);
//span.removeChild(span.firstChild);
if (status < 11) {
span.className = "snippetLoaded";
if (status < 11) {
span.className = "snippetLoaded";
//span.setAttribute("class", "snippetLoaded");
} else {
span.className = "snippetError";
//span.setAttribute("class", "snippetError");
}
var snippetNode = document.createTextNode(snippetText);
span.appendChild(snippetNode);
}
} else {
span.className = "snippetError";
//span.setAttribute("class", "snippetError");
}
var snippetNode = document.createTextNode(snippetText);
span.appendChild(snippetNode);
}

Loading…
Cancel
Save