• Register
0 votes
92 views

Problem :

I am getting following error
cross-origin request blocked: the same origin policy disallows reading the remote resource at
6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

Please note the JSONP or "JSON with padding" is a communication technique used in JavaScript programs which are running in web browsers to request data from a server which is in a different domain, something got  prohibited by the typical web browsers because of the same-origin policy. Also JSONP takes advantage of the fact that browsers are not enforcing the same-origin policy on script tags. So for JSONP to work, a server must know how to reply with JSONP-formatted results. Please note JSONP does not work with JSON-formatted results.

 $.ajax({
        type: "GET",
        url: 'http://www.oxfordlearnersdictionaries.com/search/english/direct/',
        data:{q:idiom},
        async:true,
        dataType : 'jsonp',   //you can use jsonp for cross origin request
        crossDomain:true,
        success: function(data, status, xhr) {
            alert(xhr.getResponseHeader('Location'));
        }
    });

Further Readings :

9 7 4
38,600 points

Related questions

0 votes
2 answers 1.9K views
1.9K views
Problem : Uncaught domexception: blocked a frame with origin from accessing a cross-origin frame:I am trying to load the <iframe> in my HTML page and want to access the elements within it using the Javascript, however when I want to execute my code, I face the below ... || iframe.contentWindow.document; var mytarget = mydoc.getElementById("my-target-id"); mytarget.innerHTML = "Found it!"; }); });
asked Dec 4, 2019 alecxe 7.5k points
0 votes
1 answer 4 views
4 views
Problem: reason: cors header &lsquo;access-control-allow-origin&rsquo; missing.
asked 5 days ago Ethan ross 1.8k points
0 votes
1 answer 469 views
469 views
Problem : I have spent over the 10 hours in finding the exception or the special character to find in the code but I am unable to find it. I have already checked every similar messages in here. I am facing below error: Syntaxerror: json.parse: unexpected character at line 1 ... my form after that I am sending all the inputs to the main.js to validate it. So, I am just looking for the third-eye.
asked Dec 23, 2019 alecxe 7.5k points
0 votes
1 answer 7 views
7 views
I have a function foo which makes an asynchronous request. How can I return the response/result from foo? I tried returning the value from the callback, as well as assigning the result to a local variable inside the function and returning that one, but none of those ways actually ... response; // return response; // <- I tried that one as well }); return result; // It always returns `undefined` }
asked Nov 10, 2020 Han Li 710 points
0 votes
1 answer 2 views
2 views
Problem: uncaught domexception: blocked a frame with origin "null" from accessing a cross-origin frame.
asked 4 days ago Muneeb Saadii 2.4k points
1 vote
1 answer 12 views
12 views
Problem: I'm new to Javascript and am learning the basics via a textbook that focuses on its applications in IE 7+ and Firefox 2+. However, I am using Chrome and am getting the following error when running the program given in the book: "blocked a frame of origin ' ... tell me what is causing the error and how I can fix it? blocked a frame with origin "null" from accessing a cross-origin frame.
asked 4 days ago Sofia Castro 4.2k points
0 votes
0 answers 8 views
8 views
Problem: cara mengatasi datatables warning table id table ajax error
asked Feb 17 Dan phillip 1.9k points
0 votes
1 answer 7 views
7 views
Problem: I am trying to submit data from a form to a database. Here is the form I am using: <form name="foo" action="form.php" method="POST" id="foo"> <label for="bar">A bar</label> <input id="bar" name="bar" type="text" value="" /> <input type="submit ... redirect. Using jQuery and ajax, is it possible to capture all the data from the form and send it to a PHP script (in the example, form.php )?
asked Feb 15 sasha 12.9k points
0 votes
1 answer 19 views
19 views
Problem: Hello, is there any demo that performs a live table entry. I mean, when you type something in a table, it will automatically be saved to the database like the microsoft excel?
asked Nov 12, 2020 Grace Butan 340 points