title: Pass JSON with jquery ajax to a variable in PHP
body: <p>This script doesn't work to pass data in a variable on PHP.</p>
  
  <p><strong>script.js</strong></p>
  
  <pre><code>$(document).on('click', '.variant_model', function(){
      var model_id = this.id;
      $.ajax({
          type: "POST",
          url: "http://www.mod-fusion.fr/console",
          //dataType: 'json',
          data: {"model_id":model_id},
          success: function(){
              $('#result').html(model_id); // work fine
          }
      });
  });
  </code></pre>
  
  <p><strong>script.php</strong></p>
  
  <pre><code>echo '&lt;li&gt;
      &lt;a href="#" id="'.$v['modelId'].'" class="variant_model"&gt;
          &lt;span class="'.$v['brand_name'].'_text"&gt;'.$v['model_name'].'&lt;/span&lt;/a&gt;
      &lt;/li&gt;';
  
  $return = $_POST;
  if(isset($return)){
      $return["model_id"] = json_encode($return);
      echo json_encode($return); // doesn't work, it return {"model_id":"[]"}
  }
  echo'&lt;div id="result"&gt;&lt;/div&gt;'; // work fine
  </code></pre>
  
  <p>Thank's to find solution with me.</p>