When submitting a form, I am using ajax and event.preventDefault()
so the screen will not be reloaded. In my project, I made a small MVC structure, where the URL that step is the path that leads to the desired controller.
When I submit the form via POST without event.preventDefault()
everything works normally. But when I put such code, nothing happens in the system, as if the form data were not sent. I'm breaking my head with it.
Here is the snippet of code:
$(document).ready(function() {
$('form').submit(function(event){
var formDados = jQuery(this).serialize();
$.ajax({
type : 'POST',
url : 'http://127.0.0.1/projeto/index.php?path=capacitacao/adm',
data : formDados,
dataType : 'json',
encode : true,
success:function(result){
console.log(result);
}
})
event.preventDefault();
});
});