need help with AJAX script

Here non-phpBB topics can be discussed.
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
User avatar
sanis
New member
New member
Posts: 21
Joined: 26 Sep 2006, 17:00
Location: Lithuania / Kaunas / Romaniai
Contact:

need help with AJAX script

Postby sanis » 25 Mar 2007, 09:31

hello,
i have found a little script in the internet - pagerank counter.
It uses this AJAX code:
[code]var xml = xmlObject();
var url;
var button;
var result;
function xmlObject () {
if (typeof XMLHttpRequest == 'undefined') {
objects = Array(
'Microsoft.XmlHttp',
'MSXML2.XmlHttp',
'MSXML2.XmlHttp.3.0',
'MSXML2.XmlHttp.4.0',
'MSXML2.XmlHttp.5.0'
);
for (i = 0; i < objects.length; i++) {
try {
return new ActiveXObject(objects);
} catch (e) {}
}
} else {
return new XMLHttpRequest();
}
}
function resultElement () {
if (!document.getElementById('result')) {
result = document.createElement('div');
result.id = 'result';
document.body.appendChild(result);
}
}
function handleResults () {
if (xml.readyState == 4) {
if (xml.responseText == 'url.blank') {
result.innerHTML = 'Įveskite tinkamą adresą';
} else {
result.innerHTML = xml.responseText;
}
} else {
result.innerHTML = 'Kraunasi..';
}
}
function getResults () {
resultElement();
xml.open('get', 'results.php?url=' + escape(url.value));
xml.onreadystatechange = handleResults;
xml.send(null);
}
function loadHandler () {
url = document.getElementById('url');
button = document.getElementById('button');
button.onclick = getResults;
}
window.onload = loadHandler;[code]
Ant there is a problem - when i press sumbit button my any browser goes not responsing for 3-5secs. How can i fix this "bug"?
See example in [i]pagerank.portalas.us.
Thanks.

[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests