English

- AJAX.

AJAX (Asynchronous Javascript and XML), .

 

///////////////////AJAX START//////////////////////////

// ᒺ XMLHttpRequest AJAX-

function createXmlHttpRequestObject(){

var xmlHttp;

try {xmlHttp = new XMLHttpRequest();}

catch(e)

{

var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");

for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++){

try{xmlHttp = new ActiveXObject(XmlHttpVersions[i]);}

catch (e) {}

}

}

if(!xmlHttp)alert("Error creating the XMLHttpRequest object.");

else return(xmlHttp);

}

 

// - .

requestXmlHttp = function(obj/*ᒺ XMLHttpRequest */,url/* , , */,hFunction/*-*/,method/* p=POST, g=GET*/,values/* () */){

if(obj){

try{

if(obj.readyState == 4 || obj.readyState == 0){

method = (method=='g')?'GET':'POST';

values = (values)?values:(method=='POST')?'':null;

obj.open(method, url, true);

obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

obj.send(values);

obj.onreadystatechange = function(){recieveXmlHttp(obj,hFunction);};

}

}

catch(e){ }

}

};

 

// readyState, -.

recieveXmlHttp = function(obj,f){

if(!obj)return 1;

if (obj.readyState == 4) {

if (obj.status == 200) {

try {

response=obj.responseText;//³

if(response!=''){f(response,obj.responseXML}//³ XML

}

catch(e){}

}

else {alert(obj.statusText);}

}

};

 

/////////////////// AJAX END//////////////////////////

 

 

1: AJAX

// ᒺ

XmlHttpCourse = createXmlHttpRequestObject();

 

//

function checkcours(){

requestXmlHttp(XmlHttpCourse,"course.xml",appendCheckcours,'g','');

}

 

//

function appendCheckcours(cont,rXML)

{

if(!cont)return false;

try{USD = rXML.getElementsByTagName('USD').item(0).firstChild.data;}

catch(e){ USD = false;}

 

try{EUR = rXML.getElementsByTagName('EUR').item(0).firstChild.data;}

catch(e){ EUR = false;}

d.getElementById('cusd').innerHTML = (USD)?((USD/1)?parseFloat(USD).toFixed(3):rcV.USD):'...';

d.getElementById('ceur').innerHTML = (EUR)?((EUR/1)?parseFloat(EUR).toFixed(3):rcV.EUR):'...';

}

 

 

2:

// ᒺ

XmlHttpContent = createXmlHttpRequestObject();

 

//

function loadcontent(num){

requestXmlHttp(XmlHttpContent,"indention"+num+".txt",function(cont){appendIndention(num,cont)},'g','');

d.getElementById('indention'+num).innerHTML = "...";

}

 

//

function appendIndention(num,content)

{

if(!content)return false;

d.getElementById('indention'+num).innerHTML = content;

}



: ; e-mail: me [] petkus.info