I am not sure if this is even possible but I have a page where an event can be added:
JS
$("#events-form").on("submit", function(e) {
$.ajax({
url : "/admin/shop/add_event",
type : "post",
data : new FormData( this ),
processData: false,
contentType: false,
cache : false,
success: function(data){
},
error: function(data){
}
});
e.preventDefault();
});
PHP /admin/shop/add_event
public function add_eventAction()
{
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$category_id = filter_input(INPUT_POST, 'category_id', FILTER_SANITIZE_NUMBER_INT);
$sub_category_id = filter_input(INPUT_POST, 'sub_category_id', FILTER_SANITIZE_NUMBER_INT);
$event_name = filter_input(INPUT_POST, 'event_name', FILTER_SANITIZE_STRING);
$event_date = filter_input(INPUT_POST, 'event_date', FILTER_SANITIZE_STRING);
$event_id = $this->shop->evenement_toevoegen($category_id,$sub_category_id,$event_name,$event_date);
}
}
$event_id is representing the last_insert_id(). Now I am wondering if it is possible to pass this value back to the above Javascript to use in the succes function?
Thank you in advance