(file) Return to testAjaxRequest.html CVS log (file) (dir) Up to [Development] / ajaxlib / test

File: [Development] / ajaxlib / test / testAjaxRequest.html (download) / (as text)
Revision: 1.4, Sun Apr 3 16:32:26 2005 UTC (5 years, 5 months ago) by ignatzmo
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
fixed comment

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

<script language="JavaScript" src="/lib/js/jsunit/app/jsUnitCore.js" type="text/javascript"></script>
<script language="javascript" src="../AjaxRequest.js" type="text/javascript"></script>
<style type="text/css">
/*<![CDATA[*/
 div.c2 {border: 1px dotted black;padding:4px;}
 div.c1 {font-weight: bold; margin-top: 32px}
/*]]>*/
</style>
  </head>
  <body>

    <div class="c1">
      Msg
    </div>
    <div id="msg" class="c2"></div><script language="javascript" type="text/javascript">
//<![CDATA[

  var count = 0;
  function showMessage( msg ) 
  {
    var bMsg = document.getElementById('msg')
    bMsg.innerHTML = count + ": " + msg + '<br/>' + bMsg.innerHTML
    count++
  }

  function showSource(str)
  {
    showMessage("AjaxRequest.asynchronous returns " + str)
  }

  showMessage("PING TEST")

  var http = new AjaxRequest()
  http.setTarget("/lib/js/ajaxlib/test/ping.php")

  http.requestHeaders.Accept = 'text/plain'

  ////////////////////////////////////////////////////////////
  // SYNCHRONOUS 

  var pingGet = http.get()
  // Should return ping
  if (pingGet == "ping")
  {
    showMessage("AjaxRequest.synchronousGet() returns ping: successful.")
  }
  else
  {
    showMessage("AjaxRequest.synchronousGet() returns " + pingGet + ": failure.")
  }

  http.setForm(new URLBuilder("word", "ping"))
  var pingPost = http.post()
  // Should return pong
  if (pingPost == "pong")
  {
    showMessage("AjaxRequest.synchronousPost() returns pong: successful.")
  }
  else
  {
    showMessage("AjaxRequest.synchronousPost() ping Failed... returned ")
  }

  ////////////////////////////////////////////////////////////
  // ASYNCHRONOUS 

  // It knows it's asynchronous because you've passed in a closure.

  // Should return pang
  http.get(showSource)

  // Should return pong
  http.post(showSource)

  http.setForm(new URLBuilder("word", "foo"))

  // Should return value for word
  http.post(showSource)

//]]>
</script>
  </body>
</html>

root@ad1455.com
Powered by
ViewCVS 0.9.2