Jump to content

shamuntoha

Members
  • Posts

    55
  • Joined

  • Last visited

    Never

Everything posted by shamuntoha

  1. Keeping as backup for reference AJAX standard for quick uses. /** * @xmlHttp used to ajax handle * -------------------------------------------- * Default STandard use */ var xmlHttp; /** * @ajax_maincall * Call this from your HTML events */ function ajax_main(){ // Create ajax ajax_connect(2,2,3,4); /* * Start auto reload * In case of real time data query * Optional */ ajax_listen(); } /** * @GetXmlHttpObject used to detect the browser * Supported - Firefox, Opera , Safari, IE * */ function GetXmlHttpObject(){ var xmlHttp=null; try{ // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e){ // Internet Explorer try{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }catch (e){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } /** * @ajax_connect * Use query mysql data or other * by php, asp, jsp */ function ajax_connect(str1, str2, str3, str4){ // Set xmlHttp object for browser xmlHttp=GetXmlHttpObject(); // Condition for browser if (xmlHttp==null){ alert ("This browser does not support AJAX!"); return; } /* * Variable setup for php or asp or jsp */ var url="username_password_others.php"; url=url+"?str1="+str1+"&str2="+str2+"&q3="+str3+"&q4="+str4; // Must be used , dont change for caching url=url+"&sid="+Math.random(); /* * Call output event * Query output represent * *condition can be removed */ if(str1=="2"){ xmlHttp.onreadystatechange=ajax_dataarival1; }else{ xmlHttp.onreadystatechange=ajax_dataarival2; } // Execute GET method xmlHttp.open("GET",url,true); // Send Get or Post method xmlHttp.send(null); } /** * @ajax_dataarival1 * Login failure * */ function ajax_dataarival1(){ if (xmlHttp.readyState==4){ // Will replace the mother page. // html: <div id="s1"> replace me </div> $tim = time(); document.getElementById("s1").innerHTML=$tim; } } /** * @ajax_dataarival2 * Login failure * */ function ajax_dataarival2(){ if (xmlHttp.readyState==4){ // Will replace the mother page. // html: <div id="s2"> replace me </div> $tim = time(); document.getElementById("s2").innerHTML=$tim; } } /** * @ajax_listen * Timer to ping and pong * Optional timer */ var tImer; function ajax_listen(){ ajax_connect(1,2,3,4); cOunter=cOunter+1; tImer=setTimeout("ajax_listen()",1000); }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.