0

I need read to read remote content. I read that should be send header Access-Control-Allow-Origin. I did that but still get this error. Here is script code

        $.ajax({
            url:'http://bbc.co.uk',
            headers: {'Access-Control-Allow-Origin': '*'},
            success:function(json){
                // do stuff with json (in this case an array)
                alert("Success");
            },
            error:function(){
                alert("Error");
            }
        });

I see Access-Control-Allow-Origin in the sent headers. What is wrong?

2 Answers 2

4

You should be getting this error:

No 'Access-Control-Allow-Origin' header is present on the requested resource.

It says that the header is missing from the requested resource, which is what you get in the response.

You are putting it in the request, where it does nothing useful. Your JavaScript can't give itself permission to access other servers. The server you are trying to access has to give you permission.

Sign up to request clarification or add additional context in comments.

Comments

0

You must have `

headers: {'Access-Control-Allow-Origin': '*'},

in PHP file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.