title: Why doesn't this ajax function that uses a url work?
body: <p>In <code>index.html</code> under body tag:</p>
  
  <pre><code>&lt;a href="javascript:setTempInc()"&gt;+&lt;/a&gt; &lt;a href="javascript:setMode(0)"&gt;-&lt;/a&gt;
  </code></pre>
  
  <p>and under <code>&lt;head&gt;&lt;script type="text/javascript"&gt;:</code></p>
  
  <pre><code>var url = "get.php";
  
  function ajaxRequest()
  {
      var xmlhttp = new XMLHttpRequest();
  
      xmlhttp.onreadystatechange = function()
      {
          if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200)
          {
              var jsondata = eval("(" + xmlhttp.responseText + ")"); //retrieve result as an JavaScript object
  
              document.getElementById("y").innerHTML = jsondata.y;
  
          }
      }
  
      xmlhttp.open("GET", url, true);
      xmlhttp.send();
  }
  
  function setTempInc()
  {
      var oldUrl = url;
      url = url + "9001" + jsondata.y;
      ajaxRequest();
      url = oldUrl;
  }
  </code></pre>
  
  <p>I don't understand where the problem is. <code>url</code> is a string and <code>jsondata.y</code> is a int but the script doesn't work!</p>
  
  <p>This function does, though:</p>
  
  <pre><code>function setMode(val)
  {
      var oldUrl = url;
      url = url + "91" + val + "000";
      ajaxRequest();
      url = oldUrl;
  }
  </code></pre>