title: JQuery Ajax is sending GET instead of POST
body: <p>The following code triggers a GET instead of a POST HTTP request.</p>
  
  <pre><code>function AddToDatabase() {
    this.url = './api/add';
  }
  
  AddToDatabase.prototype.postData = function(dataToPost) {
  $.ajax({
      type: "POST",
      url: this.url,
      data: dataToPost,
      context: this,
      success: this.onSuccess
    });
  };
  
  
  var AddToDatabase = new AddToDatabase();
  data = {data: 'coucou'};
  AddToDatabase.postData(data);
  </code></pre>
  
  <p>Why, and how can I get a POST ?</p>
  
  <hr>
  
  <p>I see in Google Chrome Inspect and Firefox Inspect that the browser sends a GET. Here is from Chrome:</p>
  
  <blockquote>
    <p>Request URL:http://localhost/SAMPLE-CODES/UPDATE%20MYSQL/api/add/
    Request Method:GET Status Code:200 OK</p>
  </blockquote>
  
  <hr>
  
  <p><strong>SOLVED</strong></p>
  
  <p>The URL called './api/add' was to actually post to './api/add/index.php'. Turns out that calling './api/add<code>/index.php</code>' or './api/add<code>/</code>' gives me a POST request.</p>
  
  <p>It was just a wrong URL, but for some reason I was getting a successful GET request to '.api/add/'.</p>