//javascript Object: ajax Object
// Created By RexLee
function Ajax(url,data){
this.url=url;
this.data=data;
this.browser=(function(){
if(navigator .userAgent.indexOf("MSIE")>0) {
();
};
Ajax.prototype={
get:function(){
var result;
var xmlhttp;
if(this.browser=='MSIE' ){
try{
xmlhttp=new ActiveXObject('microsoft.xmlhttp');
}catch(e){
xmlhttp=new ActiveXObject ('msxml2.xmlhttp');
= xmlhttp.responseText;//Closure, this cannot be used. Attributes
};
xmlhttp.open('GET',this.url '?' this.data,false);//true cannot fetch data, why?
return result;
},
post:function(){
var result;
var xmlhttp;
if(this.browser=='MSIE'){
xmlhttp=new ActiveXObject ('microsoft.xmlhttp'); {
result = xmlhttp .responseText;//Closure, cannot use this. attribute
}; > xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//In POST, this sentence must be
xmlhttp.send(this.data);
}
};
//var a=new ajax('opp2.js','');
//alert('by GET\n' a.get( ))
//alert('by POST\n' a.post());
////////////////////////// //////
window.onload=function(){
document.getElementById("btn").onclick=function(){
var p= document.getElementById("t").value;
var a=new Ajax("phpOOP/getPage.php","page=" p);
document.getElementById("box").innerHTML=a .get();
};
}