title: post json to a codeigniter method in controller, formerly post was made in jquery
body: <p>I need to post a json to a method in codeigniter 2.2.0, that post was made in a view with a jquery-ajax, like this:</p>
  
  <pre><code>function envia_mail_ajax(numero, form_data, ruta){  
  var iddiv="#mail_"+numero;
  window.setTimeout(
      function(){
      $.ajax({
              url: "&lt;?php site_url('emailmasivo'); ?&gt;/" +ruta+ "/" +numero, 
              cache: false,
              type: 'POST',
              data: form_data,
              dataType: "json",
              success: function(html){
                  $( iddiv ).append(html.mensaje+"\n"+'&lt;br /&gt;');
              }   
          });
      }, 600);
  
  }
  </code></pre>
  
  <p>and it was used like this (within a loop over <code>i</code>):</p>
  
  <pre><code>envia_mail_ajax(i,
    {para:correos_e[i],id_masivos:id_masivos_e[i],id_mat_referencia:id_mat_referencia_e[i],
              id_tipouser:id_tipouser_e[i],nombre:nombres_e[i], sexo:sexos_e[i], matricula:matriculas_e[i], passa:passa_e[i],id_cuenta:cuenta_id},
                  "&lt;?php echo $r_ajax; ?&gt;");
  </code></pre>
  
  <p>now, I´m writing all that in such a way that no view will be needed, in order to make it possible to run it from the terminal´s commands line, essentially, this is telling me to POST to the controller´s method <code>"&lt;?php echo site_url('emailmasivo'); ?&gt;/" +ruta+ "/" +numero</code> the data in form_data; to do this I wrote a method based in a lecture I found here <a href="http://thisinterestsme.com/sending-json-via-post-php/" rel="nofollow">POST json to PHP</a>, my method is:</p>
  
  <pre><code>function procesaInfo($Arreglo, $numero){
  $url = $Arreglo['r_ajax'];
  
  $ch = curl_init(echo site_url('emailmasivo') . $url . "/" . $numero);
  
  $jsonData = array(
      'para' =&gt; $Arreglo['lista_mails']['correos_e'][$numero],
      'id_masivos' =&gt; $Arreglo['lista_mails']['id_masivos_e'][$numero],
      'id_mat_referencia' =&gt; $Arreglo['lista_mails']['id_mat_referencia_e'][$numero],
      'id_tipouser' =&gt; $Arreglo['lista_mails']['id_tipouser_e'][$numero], 
      'nombre' =&gt; $Arreglo['lista_mails']['nombres_e'][$numero], 
      'sexo' =&gt; $Arreglo['lista_mails']['sexos_e'][$numero],
      'matricula' =&gt; $Arreglo['lista_mails']['matriculas_e'][$numero],
      'matriculas_e' =&gt; $Arreglo['lista_mails']['passa_e'][$numero],
      //'id_cuenta' =&gt; $Arreglo['lista_mails']['cuenta_id'][$numero]
      'id_cuenta' =&gt; $Arreglo['id_cuenta']
      );
  
      $jsonDataEncoded = json_encode($jsonData);
  
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); 
      $result = curl_exec($ch);
      }
  </code></pre>
  
  <p>the problem is that when I try to use that method like this:</p>
  
  <pre><code>function proceso_envia($nuevoArreglo){
  
  $hola = "hola";
  //echo $cuenta_id = $nuevoArreglo['id_cuenta'].PHP_EOL; 
  //print_r($nuevoArreglo['lista_mails']['correos_e']);
  
  if(count($nuevoArreglo['lista_mails']['correos_e']) != 0){  
      $j = 0; 
      for($i = $nuevoArreglo['ini'] ; $i &lt; count($nuevoArreglo['lista_mails']['correos_e']) ; $i++){
          if($nuevoArreglo['lista_mails']['correos_e'][$i] != NULL){
              $j = $j+1;
              sleep(1);
              echo "si llega!".PHP_EOL;
              $this-&gt;procesaInfo($nuevoArreglo, $i);
          }
      }
    } 
  }
  </code></pre>
  
  <p>it seems that no data are being POST to my method, and worst, not even the method is being reached, how do I know? well, I used an <code>echo "I´m here!";</code> at the very beginning of the <code>proceso_envia</code> function, and nothing was displayed... am I doing it right? how do I post correctly data to a CI method in a controller? thanx i.a. for your help!</p>