Alright? I've just started the Jquery + Spring MVC study. I'm developing an application where a person populates a phone field and through the pre-set a combo will be populated with the state and all cities of this state for the user to select. Here is my code example:
HTML
<div class="div-estado col-sm-3 ">
<input type="text" class="form-control row nomeEstado" id="estado" th:field="*{estado}" name="estado" readonly="readonly">
</input>
</div>
SCRIPT
$('.js-telefone').change(function(){
var numTelefone = $('.js-telefone').val();
var preFixo = numTelefone[1]+numTelefone[2];
var urlRequisicao = '/sistemas/todasCidades';
var response = $.ajax({
url: urlRequisicao,
type:'PUT',
data:{
numPreFixo:preFixo
}
});
CONTROLLER
@RequestMapping(value ="/todasCidades", method=RequestMethod.PUT)
public @ResponseBody String listaTodasCidades(@ModelAttribute String numPreFixo ) {
System.out.println("Prefixo:"+numPreFixo);
return "ok";
}
The request is being submitted I can see through the Chrome developer tools, but I am not able to access the number being sent, System.out.println is printing null. can anybody help me?