I have a update page and in the form I have a hidden field with the id:
<input name="pakket_id" id="pakket_id" type="hidden" value="<?= $pakket_details['pakket_id']; ?>">
I use the following function to make the update happen:
$("#pakket-formulier").on("submit", function(e) {
var pakket_id = $("#Pakket_id").val();
$.ajax({
url : "/admin/pakketten/pakket_wijzigen",
type : "post",
data : new FormData( this ),
processData: false,
contentType: false,
cache : false,
success: function(data){
setTimeout(function() {
window.location.href = "/admin/pakketten/pakket_details/" + pakket_id;
}, 1000)
},
error: function(data){
}
});
e.preventDefault();
})
I general the function is executing well. only var pakket_id is not regognized because I get a undfined on the id. in de redirect:
window.location.href = "/admin/pakketten/pakket_details/" + pakket_id;
What am I doing wrong? Thank you in advance