La copia del código es la siguiente:
// objeto javascript: objeto ajax
// creado por rexlee
function ajax (url, data) {
this.url = url;
this.data = data;
this.browser = (function () {
if (navigator.useragent.indexof ("msie")> 0) {
regresar "msie"; // es decir, navegador
}demás{
devolver "otro"; // otro
}}) ();
};
Ajax.prototype = {
get: functer () {
resultado var;
var xmlhttp;
if (this.browser == 'msie') {
intentar{
xmlhttp = new ActiveXObject ('Microsoft.xmlhttp');
} catch (e) {
xmlhttp = new ActiveXObject ('msxml2.xmlhttp');
}
}demás{
xmlhttp = new xmlhttprequest ();
};
xmlhttp.onreadyStateChange = function () {
resultado = xmlhttp.esponsetext; // cierre, este atributo no se puede usar.
};
xmlhttp.open ('get', this.url+'?'+this.data, falso); // true no puede rastrear datos, ¿por qué?
xmlhttp.send (nulo);
resultado de retorno;
},
Publicar: function () {
resultado var;
var xmlhttp;
if (this.browser == 'msie') {
xmlhttp = new ActiveXObject ('Microsoft.xmlhttp');
}demás{
xmlhttp = new xmlhttprequest ();
};
xmlhttp.onreadyStateChange = function () {
resultado = xmlhttp.esponsetext; // cierre, este atributo no se puede usar.
};
xmlhttp.open ('post', this.url, falso); // debe establecerse en falso, de lo contrario, el respirado no se puede rastrear
xmlhttp.setRequestHeader ("Content-type", "Application/X-WWW-Form-URLENCODEDED"); // En la publicación, esta oración debe
xmlhttp.send (this.data);
resultado de retorno;
}
};
// var a = new Ajax ('opp2.js', '');
// alerta ('por get // n'+a.get ())
// alerta ('por post // n'+a.post ());
/////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// /////////////////////////////////////////////// ////
window.onload = function () {
document.getElementById ("btn"). onClick = function () {
var p = document.getElementById ("t"). valor;
var a = new Ajax ("PhPoop/getPage.php", "Page ="+P);
document.getElementById ("box"). innerhtml = a.get ();
};
}