title: Ajax Slim Framework
body: <p>I am working on a ajax to call the slimframework API and post data to the DB. But ajax PUT do not work? I keep getting a 404 in ajax .</p>
  
  <p><strong>This works</strong></p>
  
  <pre><code>&lt;form action="http://myapi.com/api/key/514315/push" method="post"&gt;
  &lt;input type="input" name="test" value="test"&gt;
  
  &lt;input type="submit" value="Submit"/&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>Trying in Ajax, this oes not work</strong>  : returns 404 when sending data, as if you accessed API without sending a put request.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var Data = [
      {
          "Name" : 'Home',
          "Description" : "This is a test description",
          "Keywords" : "Keyword One, Two, Threeh",
          "Menu" : 1,
          "Parent" : 0
      },
      {
          "Name" : 'About',
          "Description" : "This is a About description",
          "Keywords" : "Keyword One, Two, Threeh",
          "Menu" : 2,
          "Parent" : 0
      }
  
  ];
  
  var rootURL = "http://myapi.com/api/key/514315/push";
  
  $.each(Data, function(key, value) {
  
      $.ajax({
          type: 'POST',
          contentType: 'application/json',
          url: rootURL,
          dataType: "json",
          data: Data[key],
          success: function(data, textStatus, jqXHR){
              alert('Article Added');
          },
          error: function(jqXHR, textStatus, errorThrown){
              alert('Add Article error: ' + textStatus);
          }
      });
  
  });
  </code></pre>
  
  <p></p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>$app-&gt;post('/key/:key/push', function ($key) {
  
  
          $app = new \Slim\Slim();
  
          $body = $app-&gt;request-&gt;getBody();
  
          $singleRequest =  $app-&gt;request-&gt;params('test');
  
          echo "&lt;pre&gt;";
          print_r($body);
          echo "&lt;/pre&gt;";
  
          echo "&lt;hr&gt;";
  
  
          echo "&lt;pre&gt;";
          print_r($singleRequest);
          echo "&lt;/pre&gt;";
  
  
  });
  
  $app-&gt;run();
  </code></pre>
  
  <p>Any Ideas?</p>