I need to fill in my fields after selecting one.
My JSON is as follows:
[{"codeVisit":"3EE","segmentVisit":"industria","streetVisit":"Rua Francisco Leandro Cunha","neighbVisit":"Vila","countryVisit":"Brasil","client":"5580262b600e53e82069bbeb"}]
And it's at: /clienteJson
I have the fields with the names below in my HTML ( input text
, except the client which is a select
):
The client
field is a select
and after selecting it, I need the other data to be loaded automatically.
I'm doing a script as follows:
$(document).ready(function(){
$("select[name='client']").change(function(){
var codeVisit= $("input[name='codeVisit']");
var segmentVisit = $("input[name='segmentVisit']");
$(codeVisit).val('Carregando...');
$(segmentVisit).val('Carregando...');
$.getJSON(
"/clienteJson"
{ client: $( this ).val() },
function( json )
{
$( codeVisit ).val( json.codeVisit );
var s = $( segmentVisit ).val( json.segmentVisit );
console.log(s)
}
);
alert("erro")
});
});
But the fields are not loaded.
What can I do?
I'm using nodejs and mongoose.