function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
apurswaniapurswani 

Access Denied while call salesforce pages using javascript ajax

<script type="text/javascript">
function loadXMLDoc()
{
    if (window.XMLHttpRequest)
   {

       // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
   }
  else
  {

      // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 

  xmlhttp.onreadystatechange=function()
  {
       if (xmlhttp.readyState==4 && xmlhttp.status==200)
       {
            document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
       }
  }

 

  xmlhttp.open("GET","https://na7.salesforce.com/secur/frontdoor.jsp?sid=00DA0000000awHA!AQIAQAnIQGwxFcWZSZ2ptgH50O8NvMGdF4mfE2qCiCpO8nIiqeGdDobQkAZng1NvrwAl8YSd5FoIQYp.N.2_xsQjQhzhM4Z1&retURL=https://c.na7.visual.force.com/apex/apexpage",true);
xmlhttp.send();
  }


</script>



well the above code returns error : Access Denied

 

I had already logged in using login.aspx page and it is working fine. but when I tried to call javascript function on the click event of button it is throwing error: Access Denied.

 

 

 

Can you help me on this regard.

 

 

-Anil

_Prasu__Prasu_

sid in the URL is the session id which changes with every login. So if you have hardcoded it in the JavaScript then that not going to work. In the case when you login from the Login page session is maintained and that is used, so that time no Access denied message is shown.