DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 1 of 1

Thread: Ajax function only works once!

Hybrid View

  1. #1
    Join Date
    Jul 2007

    Ajax function only works once!

    Hello! I have written this test code:

    <script type="text/javascript">
    function ajaxFunction() {
      var xmlHttp;
      try { //Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
      catch (e) {
        try {
          xmlHttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
        catch (e) {
          alert("Your browser does not support AJAX!");
          return false;
      xmlHttp.onreadystatechange = function() {
        if(xmlHttp.readyState==4) {
          document.myForm.time.value = xmlHttp.responseText;
          xmlHttp.responseText = "";
    <form name="myForm">
      Name: <input type="text" onkeyup="ajaxFunction();" name="username" />
      Time: <input type="text" name="time" />
    And in time.php:
      echo date("H:i:s");
    And it works, I'm actually surprised. But what doesn’t surprise me is that the function of getting the time to the textbox only works once; the first time I release a key when the left textbox is marked the current time pops up in the right textbox, but the rest of the times (after clearing the textboxes), the same text as before will pop up again, which is the old time and not the current time! I would really appreciate some help here. Surprise me!
    Last edited by TriKri; 07-06-2007 at 05:01 PM.

Similar Threads

  1. call function for button
    By angela_quests in forum VB Classic
    Replies: 2
    Last Post: 04-13-2007, 04:57 AM
  2. Search System Tray
    By MyPlague in forum .NET
    Replies: 2
    Last Post: 03-20-2006, 06:18 PM
  3. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 04:53 AM
  4. I still need to know how the copymemory to an object works
    By Floris De Paepe in forum VB Classic
    Replies: 4
    Last Post: 03-22-2000, 03:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center