title: Calling controller function from JS file
body: <p>Im using Yii framework, i want to call controller function from JS file,</p>
  
  <p><strong>My ajax code in JS file:</strong></p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "operator/checkDisabledDates",
      data: {
          id: 1
      },
      success: function(data) {
          alert('success');
      },
      error: function(data) {
          alert("Fail");
      }
  });
  </code></pre>
  
  <p>where <code>checkDisabledDates</code> is my controller method name, and <code>operator</code> is my controller name.</p>
  
  <p>i got wrong formation of url something like,</p>
  
  <pre><code>www.example.com/operator/agent/id/4/operator/checkDisabledDates
  </code></pre>
  
  <p>my ajax url just appends at last position of existing url,
  i tried different combinations like,</p>
  
  <pre><code>url: "/operator/checkDisabledDates"
  url: "../operator/checkDisabledDates"
  url: "../checkDisabledDates"
  </code></pre>
  
  <p>nothing worked,
  but when i use in below syntax it worked,</p>
  
  <pre><code>url: "../../checkDisabledDates" 
  </code></pre>
  
  <p>Is there anyway to do this without hardcoding dots(.) like this???</p>