因此,我尝试使用以下 jQuery 代码向 Stack Exchange API 发出请求:
$.ajax({
type: 'POST',
url: 'http://api.stackoverflow.com/1.1/stats',
dataType: 'jsonp',
success: function() { console.log('Success!'); },
error: function() { console.log('Uh Oh!'); }
});
但是当我在我的机器上用 FireFox 或 Chrome 打开文件并发出请求时,我收到了这个错误:
Resource interpreted as Script but transferred with MIME type application/json.
Uncaught SyntaxError: Unexpected token :
Uh Oh!
我不知道发生了什么。我知道 Stack Exchange API 会压缩它的响应,这会造成什么麻烦吗?