I have a button that when you click it, it will show a confirmation box. If the user clicks 'ok', the word 'reached' would display inside of the div named 'EventData'.
So far the confirmation box shows when I click the button but 'EventData' won't show the word 'reached' when I confirm it.
*the 'event_id' has a value
I think the problem is with the url part where it won't go in the function
Route:
Route::post('/ArchiveEventPosts','AdminController@ArchiveEventposts')->name('ArchiveEventposts');
Script:
$(document).on('click', '.archive', function() {
var event_id = $(this).attr('event_id');
var x = confirm("Are you sure you want to archive this record?");
if (x) {
$.ajax({
method: "POST",
url: '{{ route("ArchiveEventposts") }}',
data: {
event_id: event_id
},
success: function(data) {
$('#EventData').html(data);
alert('Record Archived');
}
});
}
});
Function in the controller:
public function ArchiveEventposts(Request $request)
{
echo 'Reached';
}