AJAX request blocked by CORS policy

The problem was that the PHP AJAX function was redirecting to another page, which caused these issues. I decided to just generate a link instead of redirecting.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)