Details - Web 2.0 & AJAX :: Permission denied ??!

This thread was displayed: 1,087 times

Starting with 17th May 2007, Adobe Systems will stop offering support for any version of the discontinued InterAKT products. As a result, we will not answer to new support incidents starting with May 17th, 2007. Pending support incidents will still be followed in order to be closed. The product forums will remain open and be transformed in user-to-user forums. The general forums will be made read-only and not allow new posts or comments.

For more information about the affected products visit: www.interaktonline.com/Support/


View All View Non Threaded Newest first
  • 04-21-2006 20:34:55 GMT +2 moutaz salahat

    Hi all,

    I am new to AJAX technology.

    I have tried to write a web app to retrieve the telephone number of some person and my code was :

    <html ><head>
    <script>
    var xmlHttp; 
    function callServer()
    {

    try {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
        xmlHttp = false;
      }
    }
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
      xmlHttp = new XMLHttpRequest();
    }
    var name =document.getElementById("name").value;
    var sURL = "http://localhost/telephone.php?name="+name;
    xmlHttp.open("GET",sURL,true);
    xmlHttp.onreadystatechange = writeResponse; }

    function writeResponse()
    {
    if(xmlHttp.readyState == 4)
    {
    var e = document.getElementById("number");
    e.value = xmlHttp.responseText;
    }
    }

    </script>
    </head>

    <body>

    <div align="center">
     <div align="center">
      <table border="0" style="border-collapse: collapse" width="266" bordercolor="#FFFFFF" bordercolorlight="#000000" bordercolordark="#808080" bgcolor="#FFFFFF" dir="ltr" id="table1">
       <tr>
        <td width="79">Name</td>
        <td><input id="name" type="text" name="name" size="20"></td>
        <td width="74"><input type="button" value="Get" name="get" onclick="callServer()"></td>
       </tr>
       <tr>
        <td width="79">Telephone</td>
        <td><input id="number" type="text" name="number" size="20"></td>
        <td width="74">&nbsp;</td>
       </tr>
      </table>
     </div>
     <p>&nbsp;</div></body></html>

    and when I tried to view it an error message apeared which is "Permission denied" pointing to the read line in the code , and I ca not find an answer plz help me.

    I am using IE v 6.0

    • 04-26-2006 12:39:45 GMT +2 Andrei DRAGOMIR [InterAKT]Adobe Systems Romania staff

      Hello Moutaz. I took a look at your problem. The error message you are getting is because of security restrictions built in browsers to stop you from calling remote scripts on localhost, when you are accessing a page  other than localhost. Most likely, the address you are accessing when you are testing your page is not "http://localhost", and that is why you are getting the error. 

      Either try to :

      1. Access the test page also with "http://localhost"
      2. change the script so that it either has the corret server, or tries to autodetect it.

      I am attaching a version using the second way of solving this issue. 

      <html ><head>
      <script>
      var xmlHttp;
      function getServerName()
      {
          var str = window.location.protocol + '//' + window.location.hostname;
          return str;
      }

      function callServer()
      {

      try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e2) {
          xmlHttp = false;
        }
      }
      if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
        xmlHttp = new XMLHttpRequest();
      }
      var name =document.getElementById("name").value;
      var sURL = getServerName() + "/telephone.php?name="+name;
      xmlHttp.open("GET",sURL,true);
      xmlHttp.onreadystatechange = writeResponse;
      xmlHttp.send(null);
      }

      function writeResponse()
      {
      if(xmlHttp.readyState == 4)
      {
      var e = document.getElementById("number");
      e.value = xmlHttp.responseText;
      }
      }

      </script>
      </head>

      <body>

      <div align="center">
       <div align="center">
        <table border="0" style="border-collapse: collapse" width="266" bordercolor="#FFFFFF" bordercolorlight="#000000" bordercolordark="#808080" bgcolor="#FFFFFF" dir="ltr" id="table1">
         <tr>
          <td width="79">Name</td>
          <td><input id="name" type="text" name="name" size="20"></td>
          <td width="74"><input type="button" value="Get" name="get" onclick="callServer()"></td>
         </tr>
         <tr>
          <td width="79">Telephone</td>
          <td><input id="number" type="text" name="number" size="20"></td>
          <td width="74">&nbsp;</td>
         </tr>
        </table>
       </div>
       <p>&nbsp;</div></body></html>

      The stuff I changed is in bold. Also, you were missing the call to xmlHttp.send which actually performs the request, so I added that too. 

      Hope this solves your issue.

      Regards, 

      Andrei

Home > Support > Forums > Web 2.0 & AJAX > Details - Web 2.0 & AJAX
Adobe acquired InterAKT
InterAKT has been acquired by Adobe.
Learn more
 
© Adobe Systems Romania. All rights reserved.