1

I've look at all the cross-domain ajax questions, and still cannot figure out what is wrong with my JSONP request. All I am trying to do is get the contents of an external page, cross domain using JSONP. Unfortunately, firefox still gives this:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://stackoverflow.com/?_=1415036764663. This can be fixed by moving the resource to the same domain or enabling CORS.

Code:

var url = "http://stackoverflow.com";

$.ajax({
    url: url,
    type: "GET",
    datatype: "jsonp",   //allows cross-domain ajax without cors (GET only)
    async: true,
    cache: false,
    timeout: 15000,

    success: function(html) {
        console.log(html);
    }
});
1
  • What URL are you trying to access? JSONP (or CORS) doesn't just magically let you access arbitrary domains via AJAX. The sites you are accessing need to support these things. I'm assuming stackoverflow.com doesn't support JSONP. If you want data from StackOverflow, you need to use the API: api.stackexchange.com/docs Commented Nov 3, 2014 at 22:14

1 Answer 1

1

You have a small typo there:

…
dataType: "jsonp", // dataType instead of datatype
…

JavaScript variables and object properties are case-sensitive.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.