Ispisala skripta:

HELP:
Ovo je sadržaj diva "div_srvgen" napunjen asihronim JS http pozivom serverske skripte.
Korisnik ne čeka kao kod ibrowserovog sinhronog http requesta.
Asihroni JS http request je klijent-serversko pozivanje potprograma iz html-a
tj klient (js) poziva serverski potprogram (php) i prikazuje njegov o utput u div ili span containeru.
To je klijent-serversko web programiranje.

r r.js = reqest-response proceduralni JS library
koji sadrži sve programe za:
r r.php koji asinhrono poziva ovaj .php ovako:
1. U  :
   Za txt u div: 
      value= "?" onClick=
         
"r eqsend('AJAX_help.php','','AJAX_help','get','0')" function AJAX_help(txt_srvgen) { //AJAX_help.php stvori txt_srvgen
//get param (u url-u do 255 znakova) //0=txt (1=xml)
document.getElementById('div_srvgen').innerHTML = text;
} Za JS alert txt-a ili html-a:
value= "MSG" onClick=
"r eqsend('show_ phpparam.php' ,'param=hello&par2=drugi param','msg','get','0')"
function msg(txt_srvgen) {
document.getElementById('div_srvgen').innerHTML = txt_srvgen;
alert(txt_srvgen); // radi: onClick="msg('yyyyyyy')"
}
Za xml u div:
value="PHP XML u div/span" onClick=
"r eqsend('show_ servertime.php','','servertime_xml','post','1')"
function servertime_xml(txt_srvgen) {
var timeValue =
txt_srvgen.getElementsByTagName("timenow")[0].childNodes[0].nodeValue
document.getElementById('div_srvgen').innerHTML = timeValue;
} 2. U r r.js:
// js procedural library: crossbrowser, GET, POST param. php-a
function crr() {
// new = create request-response object //document.write('1111111 hhhhhhhhhhhh
') //document.writeln('222222222222 sss') //alert('1111111'); try { req = new XMLHttpRequest(); // e.g. Firefox } catch(err1) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (err2) { try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err3) { req = false; } } } return req; } function cbc(callfn, txt_srvgen) {
//doCallback = ime fn je varijabla eval(callfn + '(txt_srvgen)'); } function reqget(url, query, req) { //alert('2222222'); // add random number to URL to avoid IE cache problems myRand=parseInt(Math.random()*99999999); req.open("GET",url+'?'+query+'&rand='+myRand,true); //document.writeln('aaaaaa') req.send(null); } function reqpost(url, query, req) { req.open("POST", url,true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); req.send(query); } function reqsend(url, query, callfn, reqtype, getxml) { var rrobj = crr(); rrobj.onreadystatechange = function() { if(rrobj.readyState == 4) { if(rrobj.status == 200) { document.getElementById('div_srvgen').innerHTML = '' //http.responseXML.getElementsByTagName("timenow")[0]; //document.getElementById('showtime').innerHTML = //timeValue.childNodes[0].nodeValue; var txt_srvgen = rrobj.responseText; if(getxml==1) { txt_srvgen = rrobj.responseXML; } cbc(callfn, txt_srvgen); } } else { // nije r ro bj.r eady S tate == 4 document.getElementById('div_srvgen').innerHTML = '' + ' rrobj.readyState=' + rrobj.readyState + ' rrobj.status=' + rrobj.status + ' rrobj.statusText=' + rrobj.statusText ; } } if(reqtype=='post') { reqpost(url,query,rrobj); } else { reqget(url,query,rrobj); } //alert('--r s e n d ( ) kraj'); } ŠĐČĆŽ =ŠĐČĆŽ
šđčćž =šđčćž