I need some help with Laravel, PHP, jquery and ajax!
I have a employee registration page. The salary is dynamically filled when the employee occupation is selected, with jquery and ajax.
I need to validate before the post with jquery in this case?
I make the validation in back-end with laravel validation. When i have a validation error and returns from controller to view, i can't set selected salary before.
$.get('/ajax-salarios?id_cargo=' + id_cargo, function (data) {
//success data
if (data.length > 0) {
$('#salario').empty();
document.getElementById('salario').disabled = false;
$('#salario').append('<option value="">Selecione...</option>');
$.each(data, function (index, salariosObj) {
$('#salario').append('' +
'<option value="' + salariosObj.id + '">' + salariosObj.salario + '</option>' +
'');
});
} else {
$('#salario').empty();
$('#salario').append('<option value="">Selecione...</option>');
document.getElementById('salario').disabled = true;
}
});