W
W
WebDev2018-01-17 18:02:17
AJAX
WebDev, 2018-01-17 18:02:17

Damn headlines not working again?

I get an error

'No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'xxx' is therefore not allowed access. The response had HTTP status code 502.'

I have a heading
header('Access-Control-Allow-Origin: *');
Everything works for everyone, but nothing works for one person on a macbook and such errors are pouring in.
All googling comes down to adding the above heading. But sometimes others are recommended. I added everything. Here's what happened:
header('Access-Control-Allow-Origin: *');
        header('Access-Control-Allow-Headers: *');
        header('Access-Control-Allow-Methods: *');
        header('Access-Control-Request-Headers: *, x-requested-with ');

But there is no point. Ajax query using jQuery is pouring on a poppy. Tell me what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex McArrow, 2018-01-17
@AlexMcArrow

Try like this:

header('Access-Control-Allow-Origin: *', true);
header('Access-Control-Allow-Headers: *', true);
header('Access-Control-Allow-Methods: *', true);
header('Access-Control-Request-Headers: *, x-requested-with ', true);

This will definitely set the headers and if they were set before, overwrite them.
It might help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question