1

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>

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?

lisovaccaro
  • 32,502
  • 98
  • 258
  • 410
  • 1
    Are you sure that there is a JSONP service on that site? It doesn't look like it. – user123444555621 May 31 '12 at 03:57
  • http://lujanventas.com/plugins/banners is an html website. Adding callback to a url does not make it jsonp – austinbv May 31 '12 at 03:59
  • [How](http://stackoverflow.com/questions/10802449/cross-domain-ajax-call-authorize-all-requests-for-files-content) [many](http://stackoverflow.com/questions/10803476/including-banners-with-iframes-effects-on-seo) [questions](http://stackoverflow.com/questions/10804301/error-on-cross-request-origin-is-not-allowed-by-access-control-allow-origin) [are](http://stackoverflow.com/questions/10822388/pass-variable-to-external-javascript) you gonna ask on that one issue? – user123444555621 May 31 '12 at 04:04
  • @Pumbaa80 they are not about the same issue. I first wanted to do it with CORS but abandoned it since not being not cross-browser compatible. And I'm now considering an iframe as last resource. – lisovaccaro May 31 '12 at 04:16

1 Answers1

3

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

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

, 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 :)

Cheers!

despot
  • 7,167
  • 9
  • 44
  • 63