Website URL: http://evelynbelinda.rf.gd
Error Message
Access to XMLHttpRequest at https://infinityfree.net/errors/403/ (redirected from ‘mydomain/admin/photo/destroy’) from origin ‘mydomain’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Other Information
I tried to delete the photo when the button is clicked with Ajax, it seems to be working on local development, but not on InfinityFree hosting. As I read the rules, I understand that Ajax to the same domain is allowed, but why is this blocked? Here is my Ajax code:
$('#photo-list .delete').on('click', function() {
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
const photo = $(this);
$.ajax({
url : '/admin/photo/destroy',
method : 'DELETE',
dataType : 'json',
data: {
id : photo.data('id'),
filename : photo.data('filename')
},
success: function(result) {
location.reload();
}
});
}
});
});