0
votes

We are trying to use "current.json" of Yammer rest services in our jquery code

$.ajax({
    url: "https://www.yammer.com/api/v1/networks/current.json",
    jsonp: "callback",
    type: "GET",
    dataType: "jsonp",
    data: "javascript",
    contentType: 'application/json; charset=utf-8',
    success: function (response) {
        alert(1);
        myObj = response;
        readJson(response); // server response
    },
    error: function (xhr, errorText, status) {
        alert(-1);
    }

every time it goes to the error function however when we see the status code it shows 200. Also we are able to see the response (in JSON format) in browser console.

the exact error we are facing is:

Refused to execute script from 'https://www.yammer.com/api/v1/networks/current.json?callback=jQuery110203706010680180043_1429617947980&_=1429617947981' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

Does anyone have any solution for this?

Thanks.

1
did you get CORS errors when you did a plain $.getJSON? and fyi - JSONP != rest.Daniel A. White
The issue is because you set the dataType as JSONP, yet the response is coming back in standard JSON format.Rory McCrossan

1 Answers

2
votes

The issue is because you set the dataType as JSONP, yet the response is coming back in standard JSON format.

The Yammer API does not appear to support CORS or JSONP. You would need to use their provided JS SDK to make requests to it via JavaScript, instead of jQuery.