Access to XMLHttpRequest has been blocked by CORS policy

My website URL is:
http://mgs.epizy.com/dev_prj/index.php

What I’m seeing is:
error message
Access to XMLHttpRequest at ‘htt ps://infinityfree.net/errors/404/’ (redirected from ‘htt p://mgs.epizy.com/phpmysql/data.php?queryType=Select&flds=invoice_year,job_type,account_name,tot_ctc,tot_val&table=vw_tot_invoice_values&_=1584999729266’) from origin ‘htt p://mgs.epizy.com’ 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.

jqx-all.js:17 GET htt ps://infinityfree.net/errors/404/ net::ERR_FAILED

I’m using this software:
Chrome browser Version 80.0.3987.149 (Official Build) (64-bit)

Additional information:
The error occurs on loading the site main page, which itself uses a javascript file trying to retrieve data from the database (relevant code below):

var url = ‘…/data.php?queryType=’+qryType+’&flds=’+selectFlds+’&table=’+tbl;
var invoiceSource = {
datatype: “json”,
datafields: [
{ name: ‘invoice_year’, type: ‘string’},
{ name: ‘job_type’, type: ‘string’},
{ name: ‘account_name’, type: ‘string’},
{ name: ‘tot_ctc’, type: ‘number’},
{ name: ‘tot_val’, type: ‘number’}
],
url: url,
root: ‘data’,
};

If i change the url value to:
http s://mgs.epizy.com/phpmysql/data.php?queryType=’+qryType+’&flds=’+selectFlds+’&table=’+tbl;

I get the error below:

jqx-all.js:17 GET https://mgs.epizy.com/phpmysql/data.php?queryType=Select&flds=invoice_year,job_type,account_name,tot_ctc,tot_val&table=vw_tot_invoice_values&_=1584999947004 net::ERR_SSL_PROTOCOL_ERROR

The site I am trying to build uses XMLHttpRequest to get data from/to the database. How can I resolve this issue?

Thanks
mm

if you want to use phpmyadmin, you can use it in cpanel :slight_smile:

The reason you see that error is because some of pages are missing.

3 Likes

Thanks for your reply. It looks like this can be resolved by using the full path in the “url” variable

In my case, the data.php file is in a folder called phpmysql, saved inside the home folder, so I changed the url value to:

var url = ‘http://mgs.epizy.com/dev_prj/phpmysql/data.php?queryType=’+qryType+’&flds=’+selectFlds+’&table=’+tbl;

This now seems to work

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.