Level 6
we need the html as well. What kind of element is #n_serie ?
I need to get some values from the database after entering a value in a text field, but nothing happens. Here is my code:
<div class="form-group">
<label>Entrez le numéro de série</label>
<input type="text" name="n_serie" required="required" class="form-control" />
</div>
<div class="form-group">
<label>Panne signalée</label>
<span id="panne"></span>
</div>
$('#n_serie').keyup(function(){
event.preventDefault();
var form_data = $(this).serialize();
$.ajax({
url:"{{ route('Reparation.getPanne') }}",
method:"GET",
data:form_data,
dataType:"json",
success:function(data)
{
$('#panne').html(data.success);
}
});
});
$('#n_serie') is targeting an element with an id of n_serie, your input doesn't have an id, the name attribute is n_serie
// give the input an id attribute...
<input type="text" id="n_serie" name="n_serie" required="required" class="form-control" />
// ...or find the input by name instead
$("input[name='n_serie']").keyup(...)
Please or to participate in this conversation.