title: Ajax $.post("../application/controller/theScript.php" is appended to site root and not relative
body: <p>I have a set of email functions something like what is below for popping up a window that will send emails. </p>
  
  <p>.add sends a post request to the userController and returns the VIEW that is the email window. </p>
  
  <p>.init is called and sets up the handlers for the email window.</p>
  
  <p>.send is called when the send button is pressed in the email window to send the email. </p>
  
  <pre><code>var Email={
  con:"../application/controllers/",
  dialog:null,
  
  init:function(){..
  //add event handlers for email dialog
  
  send:function(){
      var emailType=$("#emailType").prop("value");
  
      var email=$("#email").prop("value");
      if(!email){this.error("Please provide a valid email address");return false}
  
      var emailTitle=$("#emailTitle").prop("value");
      if(!emailTitle){this.error("Please provide a valid email title");return false}
  
      var emailBody=$("#emailBody").prop("value");
      if(!emailBody){this.error("Please provide a valid email body");return false}
  
      if(emailType &amp;&amp; email &amp;&amp; emailTitle &amp;&amp; emailBody){
          $.post(Email.con+"userController.php",{
              sendMail:"true",
              emailType:emailType,
              email:email,
              emailTitle:emailTitle,
              emailBody:emailBody,
          });
  
          return true;
      }
  
      return false;
  },
  
  add:function(id){
          $("#"+id).on("click",function(e){
          $.post(Email.con+"userController.php",{
              showMail:"true",
              emailType:this.dataset.emailType,
          },
          function(data,status){
              if(status==='success'){
                  $("body").append(data);
                  Email.init();
              }
          });
      });
  
      return this;
  },
  
  }
  </code></pre>
  
  <p>The problem is with the send function as the path in the $.post ajax call is not correct. When add is called it finds the userController which is in a folder system something like</p>
  
  <ul>
  <li>application
  
  <ul>
  <li>controllers
  -userController.php</li>
  </ul></li>
  <li>public</li>
  </ul>
  
  <p>So the path "../application/controllers/userController.php" steps back one out of public and down the path to the controller. </p>
  
  <p>In send the path is always appended to the site root or public folder and returns something like <a href="http://theSite/application/controllers/userController.php" rel="nofollow">http://theSite/application/controllers/userController.php</a></p>
  
  <p>Why is the send ajax call not using a relative path from the site root to the controller in the once case? </p>
  
  <p>There must be 50 other ajax calls that work correctly on the site. </p>