JSONP请求:“将资源解释为脚本,但以MIME类型text/html传输" [英] JSONP request: "Resource interpreted as Script but transferred with MIME type text/html"

查看:629
本文介绍了JSONP请求:“将资源解释为脚本,但以MIME类型text/html传输"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JSONP进行第一个交叉请求,以从外部URL获取横幅.

I'm trying to do my first cross request with JSONP to get a banner from an external URL.

<script type="text/javascript">
    function handleResponse(json){
    var data = JSON.parse(json);
    alert(data);
    }
</script>
<script src="http://lujanventas.com/plugins/banners/?callback=handleResponse"></script>

我认为这段代码是一个非常基本的JSONP请求.我的问题是,我得到了错误:资源被解释为脚本,但以MIME类型text/html传输".

This code I think it's a pretty basic JSONP request. My problem is that is that I get the error: "Resource interpreted as Script but transferred with MIME type text/html".

我没有以任何方式修改文件以为请求做准备. (我相信我必须以某种方式对其进行修改,但不知道该怎么做).

I haven't modified the file in any way to prepare it for the request. (I believe I must modify it somehow but have no idea what to do).

我该怎么做才能毫无问题地获取文件?

What must I do to get the file with no problems?

推荐答案

我的jsonp请求有相同的问题.我

I had the same issue with my jsonp requests. I got

资源被解释为脚本,但以MIME类型text/plain传输

Resource interpreted as Script but transferred with MIME type text/plain

,但是一旦将响应"Content-Type"标头设置为"text/javascript",就可以解决它.但这只有在您控制服务器的情况下才能完成.因此,要么告诉lujanventas.com尝试更改"ContentType"标头,要么忽略它:)

, but once I set the response "Content-Type" header to "text/javascript", I get it resolved. But this could only be done if you control the server. So either tell lujanventas.com to try to change the "ContentType" header, or ignore it :)

干杯!

这篇关于JSONP请求:“将资源解释为脚本,但以MIME类型text/html传输"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆