Clear AJAX loader in correct state only

This commit is contained in:
Jakub Vrana 2011-03-11 22:09:54 +01:00
parent 15ab4d28a7
commit a8df780fe0

View file

@ -249,11 +249,7 @@ function ajax(url, callback, data) {
if (title) { if (title) {
document.title = decodeURIComponent(title); document.title = decodeURIComponent(title);
} }
if (xmlhttp.status) { callback(xmlhttp.status ? xmlhttp.responseText : undefined);
callback(xmlhttp.responseText);
} else {
setHtml('loader', '');
}
} }
}; };
xmlhttp.send(data); xmlhttp.send(data);
@ -287,10 +283,13 @@ function ajaxSend(url, data, popState) {
setHtml('loader', '<img src="../adminer/static/loader.gif" alt="">'); setHtml('loader', '<img src="../adminer/static/loader.gif" alt="">');
return ajax(url, function (text) { return ajax(url, function (text) {
if (currentState == ajaxState) { if (currentState == ajaxState) {
if (text === undefined) {
setHtml('loader', '');
} else {
if (!popState) { if (!popState) {
history.pushState(data, '', url); history.pushState(data, '', url);
}
scrollTo(0, 0); scrollTo(0, 0);
}
setHtml('content', text); setHtml('content', text);
var content = document.getElementById('content'); var content = document.getElementById('content');
var scripts = content.getElementsByTagName('script'); var scripts = content.getElementsByTagName('script');
@ -321,6 +320,7 @@ function ajaxSend(url, data, popState) {
jush.highlight_tag('code', 0); jush.highlight_tag('code', 0);
} }
} }
}
}, data); }, data);
} }