A cópia do código é a seguinte:
// Javascript Object: Ajax Object
// Criado por Rexlee
função ajax (url, dados) {
this.url = url;
this.data = dados;
this.browser = (function () {
if (Navigator.UserAgent.Indexof ("msie")> 0) {
retornar "msie"; // ou seja, navegador
}outro{
retornar "outro"; // outro
}}) ();
};
Ajax.prototype = {
get: function () {
VAR resultado;
var xmlhttp;
if (this.browser == 'msie') {
tentar{
xmlHttp = new ActiveXObject ('Microsoft.xmlHttp');
} catch (e) {
xmlHttp = new ActivexObject ('msxml2.xmlHttp');
}
}outro{
xmlHttp = new XmlHttPrequest ();
};
xmlhttp.onreadystatechange = function () {
resultado = xmlHttp.ResponseText; // Fechamento, este atributo não pode ser usado
};
xmlhttp.open ('get', this.url+'?'+this.data, false); // true não pode rastejar dados, por quê?
xmlhttp.send (nulo);
resultado de retorno;
},
Post: function () {
VAR resultado;
var xmlhttp;
if (this.browser == 'msie') {
xmlHttp = new ActiveXObject ('Microsoft.xmlHttp');
}outro{
xmlHttp = new XmlHttPrequest ();
};
xmlhttp.onreadystatechange = function () {
resultado = xmlHttp.ResponseText; // Fechamento, este atributo não pode ser usado
};
xmlhttp.open ('post', this.url, false); // deve ser definido como falso, caso contrário, o responseText não pode ser rastejado
xmlhttp.setRequestHeader ("conteúdo-tipo", "Application/x-www-corm-urlencoded"); // no post, esta frase deve
xmlhttp.send (this.data);
resultado de retorno;
}
};
// var a = novo ajax ('opp2.js', '');
// alert ('por get // n'+a.get ())
// alert ('por post // n'+a.post ());
/////////////////////////////////////////////////////////Tipos /////////////////////////////////////////////////////////Tipos /////////////////////////////////////////////////////////Tipos /////////////////////////////////////////////////////////Tipos /////////////////////////////////////////////////////////Tipos /////
window.onload = function () {
document.getElementById ("btn"). OnClick = function () {
var p = document.getElementById ("t").
var a = novo ajax ("phpoop/getpage.php", "página ="+p);
document.getElementById ("Box"). Innerhtml = a.get ();
};
}