0 Replies Latest reply on Nov 23, 2008 7:27 AM by Newsgroup_User

    javascript error

    Level 7
      I am trying ajax for the first time using the following code.
      When i click the select button the javascript action takes place correctly
      and i can see the ajax output in the div tag.
      However when i click the text with hyperlink tag to run the javascript, it
      gives me error.
      Please help.
      I am copying the code below-

      test.asp file
      _____________
      <html>
      <head>
      </head><body>
      <script language="JavaScript" type="text/javascript"
      src="include/ajax.js"></script>
      <script type="text/JavaScript">
      <!--
      function MM_callJS(jsStr) { //v2.0
      return eval(jsStr)
      }
      //-->
      </script>

      <form>
      Select a Customer:
      <select name="customers" onChange="showDetails(this.value)">
      <option value="ALFKI">Alfreds Futterkiste</option>
      <option value="NORTS ">North/South</option>
      <option value="WOLZA">Wolski Zajazd</option>
      </select>
      </form><p>
      <a href="#" onClick="MM_callJS('ShowDetails(\&quot;\&quot;)')">wrwetwr</a>
      <div id="txtRecordDetails"><b>Customer info will be listed here.</b></div>
      </p></body>
      </html>

      -----------
      ajax.js code
      _____________

      // JavaScript Document
      var xmlHttp

      function showDetails(str)
      {
      xmlHttp=GetXmlHttpObject();
      if (xmlHttp==null)
      {
      alert ("Your browser does not support AJAX!");
      return;
      }
      var url="";
      //var url="dbSearchRecord_details.asp";
      url=url+"?q="+str;
      url=url+"&sid="+Math.random();
      xmlHttp.onreadystatechange=stateChanged;
      xmlHttp.open("GET",url,true);
      xmlHttp.send(null);
      }

      function stateChanged()
      {
      if (xmlHttp.readyState==4)
      {
      document.getElementById("txtRecordDetails").innerHTML=xmlHttp.responseText;
      }
      }

      function GetXmlHttpObject()
      {
      var xmlHttp=null;
      try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
      catch (e)
      {
      // Internet Explorer
      try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      }
      return xmlHttp;
      }