title: Can't hit apex REST web service from javascript
body: <p>I created the sample REST api class (found here) in my developer org, and I'm trying to hit it from javascript on a visualforce page in the same org, but I'm getting the following error:</p>
  
  <p>"NetworkError: 405 Method Not Allowed - <a href="https://na9.salesforce.com/services/apexrest/Account/001E000000B9GjD" rel="nofollow">https://na9.salesforce.com/services/apexrest/Account/001E000000B9GjD</a>"</p>
  
  <p>From the guide in the link mentioned above, a 405 means "The request method does not have a corresponding Apex method."
  Any ideas? Here's the related code:</p>
  
  <p>Apex class:</p>
  
  <pre><code>@RestResource(urlMapping='/Account/*')
  global with sharing class MyRestResource {
     @HttpGet
     global static Account doGet(RestRequest req, RestResponse res) {
        ...
     }
  }
  </code></pre>
  
  <p>Visualforce page (in javascript):</p>
  
  <pre><code>var session = '{!$Api.Session_ID}';
  var Url = "https://na9.salesforce.com/services/apexrest/Account/001E000000B9GjD";
  
  xmlHttp = new XMLHttpRequest(); 
  xmlHttp.onreadystatechange = ProcessRequest;
  xmlHttp.open( "GET", Url, true );
  xmlHttp.setRequestHeader('Set-Cookie', session);
  xmlHttp.send( null );
  </code></pre>