Simple AJAX Client

Home Forums V-Control Show Case Simple AJAX Client

Viewing 1 post (of 1 total)
  • Author
  • #731

    Just thought this might help people get started.

    <!DOCTYPE html>
    <meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
    .request {margin-left:1cm;color:#770000}
    .response {color:#777777}
    .log {border:thin solid blue;margin-left:2cm;margin-right:2cm}
    body {background-color:white}
    button {background-color:white;display:block}
    <script language=”JavaScript”>
    var xmlhttp;
    if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }else{// code for IE6, IE5
    xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);

    function vcontrol(control){
    var url=”cgi-bin/scrRunTask%05″+control;
    document.getElementById(“log”).innerHTML=document.getElementById(“log”).innerHTML+'<div class=”request”>’+escape(url)+'</div>’

    if (xmlhttp.readyState==4 && xmlhttp.status==200){
    document.getElementById(“log”).innerHTML=document.getElementById(“log”).innerHTML+'<div class=”response”>’+escape(xmlhttp.responseText)+'</response>’;

    <button type=”button” onclick=”vcontrol(this.innerHTML)”>task1</button>
    <button type=”button” onclick=”vcontrol(this.innerHTML)”>task2</button>
    <button type=”button” onclick=”vcontrol(this.innerHTML)”>task3</button>
    <div id=”log” class=”log”></div>


    • This topic was modified 6 years, 6 months ago by Dierk.
    • This topic was modified 6 years, 6 months ago by Dierk Walter.
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Scroll to top