I have a function in jQuery
that gets a array
from PHP
, through $.post
. array
looks like this:
array(
'0' => array(
'ID' => '1',
'NOME' => 'João'
),
'1' => array(
'ID' => '2',
'NOME' => 'Maria'
),
'2' => array(
'ID' => '3',
'NOME' => 'Marcos'
),
)
How do I, through jQuery, add option
to a select
with the data in that array?
Example:
<select>
<option value="ID">"NOME"</option>
</select>
This is the $.post
I am receiving array
from php
$.post('/consulta/usuario', {id:id}, function(dados){
alert(dados);
}, 'json');
I get id
according to the option that the user chooses, and on the php side I'm returning array
:
echo json_encode($usuario);