Skip to content

Javascript – Debug application en Ajax

by Cyril on janvier 5th, 2010

Une utilisation originale d’AJAX pour tracker un dysfonctionnement entre le client et votre applicatif.

  • Le javascript code :

  • <script Language="JavaScript">
    var from_time = new Date();
    from_time = from_time.getTime();
    function benchmark_loading_time() {
    var to_time = new Date();
    to_time = to_time.getTime();
    var msecs = (to_time - from_time);
    //submit the result
    var req = null;
    try { req = new XMLHttpRequest(); } catch(e) {}
    if (!req) try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
    if (!req) try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
    req.open("GET", '/benchmark_loading_time.php?msecs=' + msecs + '&url=' + location.href, false);
    req.send(null);
    }
    </script>

  • L’appel dans l’HTML page:


<body onLoad="benchmark_loading_time()>

  • Cote serveur, le script PHP benchmark_loading_time.php se chargera de jouer avec les paramètres msecs et url

Source : lien

Autres articles susceptibles de vous intéresser :

From → Web

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS