title: Sending JSON from AS3 to PHP
body: <p>I really can't figure out what's wrong.</p>
  
  <p>Im sending JSON from AS3 to PHP:</p>
  
  <pre><code>var sendToPHPJson:String = com.adobe.serialization.json.JSON.encode(sqlResult);
  
  myRequest = new URLRequest("http://xxx.pl/FlashFiles/Winebook/uploadToServer.php");
  myLoader = new URLLoader;
  myVariables = new URLVariables;
  myVariables.firstProperty = sendToPHPJson;
  myLoader.addEventListener(flash.events.Event.COMPLETE,onUploadingComplete);
  myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  myRequest.method = URLRequestMethod.POST;
  myRequest.data = myVariables;
  myLoader.load(myRequest);
  </code></pre>
  
  <p>And my PHP is receiving:</p>
  
  <pre><code>&lt;?php
  include "XXX.php";
  $json=$_POST['firstProperty'];
  $data = json_decode($json);
  $answe=$data[0]-&gt;wineName;
  echo "answer='".$answe."'";
  ?&gt;
  </code></pre>
  
  <p>And i receive answer=''. But when I hardcode sendToPHPJson into PHP answer has good value.</p>
  
  <p>What can be wrong? What to change?</p>
  
  <p>*EDIT:
  I did some search and rebuild code to:</p>
  
  <p>AS3:</p>
  
  <pre><code>var url:String = "http://adres/uploadToServer.php";
  var request:URLRequest = new URLRequest(url);
  request.method = URLRequestMethod.POST;
  
  var requestVars:URLVariables = new URLVariables();
  requestVars.myObject = sendToPHPJson;
  request.data = requestVars;
  
  var loader:URLLoader = new URLLoader();
  loader.addEventListener(flash.events.Event.COMPLETE,onUploadingComplete);
  loader.load(request);
  </code></pre>
  
  <p>PHP:</p>
  
  <pre><code>&lt;?php
  include "XXX.php";
  ob_start();
  var_dump($_POST['myObject']);
  print_r($_POST);
  $content = ob_get_contents();
  ob_end_clean();
  $wynik = json_decode($content);
  echo $wynik;
  ?&gt;
  </code></pre>
  
  <p>And I still get no data in:</p>
  
  <pre><code>private function onUploadingComplete(e:flash.events.Event):void
  {
      trace("upload complete");
      trace(e.target.data);
      txtField.text = String(e.target.data);
      this.touchable = true;
  }
  </code></pre>