1
I got the following jQuery:
function clienteChange() {
var id = $('#idCliente').val();
$.ajax(
{
url:"/Administrar/clientes.endereco.php?id=" + id,
dataType : 'json',
success:function(result) {
$('[name^="cham_endereco[]"]').val(result.endereco);
$('[name^="cham_numero[]"]').val(result.numero);
$('[name^="cham_bairro[]"]').val(result.bairro);
$('[name^="cham_cidade[]"]').val(result.cidade);
}
});
var selectSolicitante = jQuery(id).parents('tr').find('select.selectSolicitante');
selectSolicitante.html('<option value="0">Carregando...</option>');
$.post("/Administrar/clientes.solicitante.php?idCliente=" + id,
{solicitante:jQuery(id).val()},
function(valor){
selectSolicitante.html(valor);
}
);
}
The first block works correctly, it displays the data in the address, number... He wanted when selecting the client, to execute this first block but also to execute the second block, searching for the first ones... I took the test, but it doesn’t work.
Follow PHP as well:
mysql_query("SET NAMES 'utf8'");
mysql_query('SET character_set_connection=utf8');
mysql_query('SET character_set_client=utf8');
mysql_query('SET character_set_results=utf8');
echo "<option>teste</option>";
The registration screen is this:
What test did you take?
– user3603
I selected the normal client... And the console did not return any errors either... But it does not also display the field options. I put a form print to better understand.
– Sr. André Baill
Would have to return the test...
– Sr. André Baill
When you perform the function
clienteChange()
?– user3603
<select class="input-xxlarge" style="width: 409px ! Important;" id="idCliente" name="idCliente" onchange="clientChange()" >
– Sr. André Baill
But what is this
select
on your screen?– user3603
At this time, I run it... type, it displays the customer’s address when it selects, but wanted when selecting the customer, also load the requester
– Sr. André Baill
This select I gave you, is the "Client"
– Sr. André Baill
The code
$.post("/Administrar/clientes.solicitante.php?idCliente=" + id,
is executed? Another question, because it is a methodPOST
and you pass the variable onURL
?– user3603
True, I can take out the GET, but it runs the url yes.
– Sr. André Baill
You can check using
console.log(valor)
beforeselectSolicitante.html(valor);
? Have you checked if you are sending theid
?– user3603
<option>test</option> Returned this in the console, but not in the field
– Sr. André Baill
Let’s go continue this discussion in chat.
– Sr. André Baill