title: Ajax POST request becomes a GET request
body: <p>I am trying out Redis and wanted to build a simple front end / back end setup to test it and to practice. The front end is HTML / Javascript / JQuery and the back end is PHP / Apache / Redis. Basically, I wanted to send a post request to the back end and receive a response, that I would then display on the web console. To send the request, I used JQuery:</p>
  
  <pre><code>var data = $("#login_form :input").serializeArray();
  
  var username = data[0]['value'];
  var password = data[1]['value'];
  
  $.ajax({
          type: "POST",
          url: "http://localhost/Convo/user.php?jsoncallback=%3F",
          dataType: "json",
          cache: false,
          data: { username: username, password: password, method: "create" },
          success: function(text){console.log("awesome");}
          });
  </code></pre>
  
  <p>I am using Firebug on Firefox to see what is really going on. In Firebug, I see a GET request being fired instead of a POST. The jsoncallback string attached to the url might be the cause, but without it, I don't get a response at all. As a side note, I am expecting json back in response. Here is my PHP code:</p>
  
  <pre><code>    error_reporting(E_ALL);
  ini_set('display_errors', '1');
  require 'Predis/Autoloader.php';
  Predis\Autoloader::register();
  
  $body = array();
  $head = array();
  
  $redis = new Predis\Client(array(
          'scheme' =&gt; 'tcp',
          'host'   =&gt; '127.0.1.1',
          'port'   =&gt; 6379,
  ));
  
  if(!$redis)
  {
      $body['status'] = "fail";
      $body['message'] = "unable to connect to database";
      $head['body'] = $body;
  
      header('Content-type: application/json');
      echo json_encode($head);
      exit;
  }
  else
  {
      $body['status'] = "success";
      $body['message'] = "connected to database!";
      $head['body'] = $body;
      $jsoncallback = $_POST['jsoncallback'];
  
      header('Content-Type: application/json');
      echo $jsoncallback . '(' . json_encode($head) . ')';
      exit;
  }
  </code></pre>
  
  <p>The jsoncallback stuff was the only way to get a response, but how do I successfully launch a true POST request without it?</p>