------- Here's my test HTML + Javascript code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Delay Test</title>

<style type="text/css">
#result {
  border : 1px solid #000000;
}
</style>

<script type="text/javascript" src="mootools-1.2.4-core-full.js"></
SCRIPT>

<script type="text/javascript">
  showRecordReq = new Request.JSON({
    url    : "delayTestAjax.php",
    method : "post",
    onFailure : function() {alert("AJAX Failure")},
    onException : function() {alert("AJAX Exception")},
    onCancel : function() {alert("AJAX Cancel")},

    onComplete : function(jsonResponse) {
      var html = "";
      for ( var item in jsonResponse ) {
        html += jsonResponse[item] + "<br>";
      }
      $("result").set("html",html);
    }
  });

  window.addEvent("domready",function() {
    $("result").addEvent("click",function() {
      var id = Math.round((Math.random() * 10) + 1);
     $("sending").set("html",id);

      showRecordReq.POST({
        id : id,
        val1 : Math.round((Math.random() * 10) + 100),
        val2 : Math.round((Math.random() * 10) + 100),
        val3 : Math.round((Math.random() * 10) + 100),
        val4 : Math.round((Math.random() * 10) + 100)
      });
    });
  });
</script>

</head>
<body>
Sending id: <span id="sending"></span>
<div id="result">&nbsp;</div>

</body>
</html>

------- Here's the PHP code:

<?php
  echo json_encode($_POST);
?>

Reply via email to