¿如何获取Ajax数据?

I need to get the records of a specific row, im rendering the data with this code:

 $(function() 
 {
    $('#id_project').on('change', function() 
    {
        var id_project = $('#id_project').val();
        $.ajax(
        {
            url: "ff.php",
            type: "POST",
            data:{id_project},
            dataType: "html",
            success: function(data)
            {
                var datos = data.datas;
                alert(datos);
            },
        })
    });
 });

Change DataType to json. A html response is expected while PHP returns json

Your JSON contains one object wrapped in an array.

Therefore, json_data.nb_informacion_general_localizacion doesn't work because you're trying to directly access the property of the object, as if "json_data" was the object.

But "json_data" is an array, and arrays don't have properties, they have indexes. Your object is stored in the first index of the array. To get it you have to reference the index of the array you want, and then you can access the properties of the object which is stored at that index.

So very simply:

json_data[0].nb_informacion_general_localizacion

will get you what you need. The [0] denotes the first index of the array (since arrays in JavaScript are zero-based).

You also need to do what is mentioned in another answer and change dataType: "html" to dataType: "json", otherwise jQuery will not treat your response as JSON, and won't turn it into a JS array.

The solution for the problem was the

$array_data[] = array('id_project' => $id_project,'nb_informacion_general_localizacion' => $nb_informacion_general_localizacion);

Just deleted that and after that, i call the data like this and works perfect, thanks to you all.

id = data.id_project
console.log(id);