I try to make a query with $ .post from JQuery doing the following:
function consultaAjax(url, val){
arreglo = { id: val };
datos = JSON.stringify(arreglo);
$.post(
url,
datos,
function(data){$("select#documentos-expedicion").html( data );}
);}
and in the controller I have the following code
public function actionGetinfo(){
$json = Yii::$app->request->post();
$data = json_decode($json[0], true); // <- aqui esta el problema
echo 'fuck '.$data; // esto no importa, solo me siento frustrado
}
$ json is a one-dimensional array containing the JSON string, (this I know thanks to the Netbeans debugger) the problem when I try to access the array is that it throws the error:
$data = $json[0]; // error "Undefined offset: 0"
$data = $json[1]; // error "Undefined offset: 1"
$data = $json['id']; // error "Undefined index: id"
If I pass it completely to "json_decode ()" it tells me that I expected a json string and that I passed an array and obvious "error".
How can I access the arrangement? Is there a procedure that is skipping me ?, and thanks in advance for the help.