1👍
You can use ajax to submit your data to view then validate the data and return the json of your response. After that you can show the alert based on your return. You can use $.ajax()
, $.get()
, $.post()
and other function based on what you need. Just make sure you can handle the data in ajax based on your response from view.
UPDATED
For you edit case you have to know more about the jQuery. Instead of
$(document).on('Valider', 'form.form', function(form)
you should
$(document).on('event', 'selector', function(form)
For event
is kind of input or something happen that you would like to handle, for example when you want to handle click then you use click
or something change you can use change
.
For selector
are some kind of id, class or other type that you got from you html element. So in your case if you want to use click
event the code would be like
$(document).on('click', '.btn-validate', function(e){
var form = $(".form").serialize();
$.ajax({
url: "url_on_your_view and already registered in you url.py",
type: "POST",
success:function(response){
alert("L'acte de naissance a été créé");
}
});
}
for your button you have to update to
<button type="input" class="btn-validate">Valider</button>