Codice:
function submit(FILE, METHOD)
{
if( document.getElementById('spy') )
{
var key = new Array('coo', 'quote', 'nofleet', 'nodif', 'nocos', 'noric', 'resize', 'save');
var key2 = new Array('coo2', 'quote2', 'nofleet2', 'nodif2', 'nocos2', 'noric2', 'resize2', 'save2');
var len = key.length;
for( var x = 0; x < len; x++ )
{
var val = document.getElementById(key[x]).checked;
document.getElementById(key2[x]).value = val;
}
}
var target = '';
var rnd = Math.random();
var num = document.forms[0].elements.length;
var url = "";
for (var i = 0; i < num; i++)
{
var chiave = document.forms[0].elements[i].name;
var valore = document.forms[0].elements[i].value;
var tipo = document.forms[0].elements[i].type;
if ( (tipo == "submit") || (tipo == "radio") || (tipo == "checkbox") )
{
}
else
{
url += chiave + "=" + valore + "&";
}
}
var parameters = url;
url = FILE + "?" + url + "&rnd" + rnd;
if (METHOD == undefined)
{
METHOD = "GET";
}
if (METHOD == "GET")
{
return ahah(url, target, '', METHOD);
}
else
{
return ahah(FILE, target, '', METHOD, parameters);
}
}
function ahah(url, target, delay, method, parameters)
{
if (method == undefined)
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req)
{
req.onreadystatechange = function()
{
//ahahDone(url, target, delay, method, parameters);
if (req.readyState == 4)
{
if (req.status == 200)
{
response = req.responseText;
}
}
};
req.open("GET", url, true);
req.send("");
}
}
if ( (method == "GET") || (method == "get") )
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req)
{
req.onreadystatechange = function()
{
//ahahDone(url, target, delay, method, parameters);
if (req.readyState == 4)
{
if (req.status == 200)
{
response = req.responseText;
}
}
};
req.open(method, url, true);
req.send("");
}
}
if ( (method == "POST") || (method == "post") )
{
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
} else if (window.ActiveXObject)
{
req = new ActiveXObject("Microsoft.XMLHTTP");
}
if (req)
{
req.onreadystatechange = function()
{
ahahDone(url, target, delay, method, parameters);
/*if (req.readyState == 4)
{
if (req.status == 200)
{
response = req.responseText;
}
}*/
};
req.open(method, url, true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.send(parameters);
}
}
//return response;
}
function ahahDone(url, target, delay, method, parameters)
{
if (req.readyState == 4)
{
if (req.status == 200)
{
//document.getElementById(target).innerHTML = ''+ req.responseText;
response = req.responseText;
}
}
}
questo codice l'ho trovato sul forum, era stato postato da debug.