0

I call the api using this:

   $.ajax({
    contentType: "text/html; charset=utf-8",
    dataType: "jsonp",
    type: "get",
    crossDomain: true,
    url: "http://data.nba.com/data/10s/html/nbacom/2013/gameinfo/20140501/0041300106_boxscore_csi.html",
    success: function (val) {
        $(".content-wrapper").text(val);
        var a = val;
    }
})

I get the error:

    Resource interpreted as Script but transferred with MIME type text/html:

which i read is not realy an error but a warning. If i paste the url in the domain it shows the return in a textarea. And if i try to debugg the code using chrome it wont reach the success but instead say:

  Uncaught SyntaxError: Unexpected token <

How can i get the html straight into my own html so that i shows the table that the call returns?

3 Answers 3

2

if the response is HTML you should change the ajax success to:

success: function (val) {
    $(".content-wrapper").html(val);
    ...

Hope this helps!

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

2 Comments

Ok, thanks! But i wont even reach the success though
Also when accessing the URL I get the content inside a textarea, you might need to use something like: var data = $(val).filter('div'); $(".content-wrapper").html(data);
0

Try changing your datatype to 'html'

5 Comments

if i do that ill get: No 'Access-Control-Allow-Origin' header is present on the requested resource.
You might want to check to see the rules for using whatever API you are using.
@JasonSilberman i don't think there is any documentation of the nbaapi :(
Access-Control-Allow-Origin message is telling you that the API site does not allow your site to do cross domain access to it. If you can, have the api provider add your site in the Access-Control-Allow-Origin header so browsers won't block you.
@DanielGustafsson By the way, it is the browser that sends the Access-Control-Allow-Origin request to the API. So if the server doesn't fulfill it, the browser will not issue your actual AJAX get request. Check out this blog for more details. link
0

I believe you are using dataType and contents type incorrectly. Try switching dataType to text/html.

1 Comment

Ill get this: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3526' is therefore not allowed access.

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.