title: magento ajax isn't working
body: <p>My controller has this function in it:</p>
  
  <pre><code>public function saveLeadDaysAction(){
          echo "works";
      }
  </code></pre>
  
  <p>And in the template phtml I am trying to this:</p>
  
  <pre><code>jq("#prodcal_leaddays").on("blur", function(e){
          $saveurl="&lt;?=$this-&gt;getUrl('prodcal/adminhtml_prodcaltab/saveLeadDays');?&gt;";
          console.log('$saveurl');
          jq.post($saveurl,{'id':'test'},function(d){
              console.log(d);
          });
      });
  </code></pre>
  
  <p>The url seems to return the entire admin dashboard page instead of the expected <code>works</code> text. However if I open the url directly in the browser, it does show the expected text.</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Oh and I have tried appending <code>?isAjax=true</code> at the end of the url, which returns: </p>
  
  <pre><code>{"error":true,"message":"Invalid Form Key. Please refresh the page."}
  </code></pre>
  
  <p><strong>EDIT:</strong> Just to clarify:-
  the <code>getUrl</code> generates a url like <code>http://localhost/devmagento/index.php/prodcal/adminhtml_prodcaltab/saveLeadDays‌​/key/d3c92257c664d8d207f5a0bdeb3edebf/</code> in the console.
  If I copy this url from the console and paste it in the browser, it works as expected and I get the <code>works</code> text.
  But when used with jQuery post, it fails and redirects to dashboard.</p>
  
  <p><strong>EDIT 2:</strong> It seems with post data, the key is wrong, cause if I change the above to use <code>GET</code>, and put the values within the <code>getUrl</code> function, it works properly, but the problem is since this is to be done by ajax, I need to change the values dynamically using javascript.</p>
  
  <p>What I did for the get thing to work is:</p>
  
  <pre><code>jq("#prodcal_leaddays").on("blur", function(e){
          $saveurl="&lt;?=$this-&gt;getUrl('prodcal/adminhtml_prodcaltab/saveLeadDays',array('id'=&gt;'test'));?&gt;";
          console.log($saveurl);
          jq.get($saveurl,function(d){
              console.log(d);
          });
      });
  </code></pre>