最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - js warning: Resource interpreted as Script but transferred with MIME type textplain - Stack Overflow

programmeradmin2浏览0评论

i´m firing an ajax/jsonp request to my cloudant app:

    var obj = $.ajax({
        url: "http://xyz",
        dataType: 'jsonp',
        success: function(data) {  
            //SOME CODE  
        },
        error: function() {
            //SOME CODE
        }
    });

the response is ok and i can read out my data. but I´m getting the following js warning:

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

i need to make this request an jsonp request (cross domain policy), AFAIK jsonp returns as a script and gets executed by the browser. do i have to set a request header? I tried it with the 'accepts' and 'converters' options, but didn't make it work yet. (I´m using GoogleChrome, but also happens in Safari/FF)

cheers, tom

PS: I want to get rid of the warning as this ajax request gets triggered every 2 seconds. So the console looks pretty bad...

i´m firing an ajax/jsonp request to my cloudant app:

    var obj = $.ajax({
        url: "http://xyz",
        dataType: 'jsonp',
        success: function(data) {  
            //SOME CODE  
        },
        error: function() {
            //SOME CODE
        }
    });

the response is ok and i can read out my data. but I´m getting the following js warning:

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

i need to make this request an jsonp request (cross domain policy), AFAIK jsonp returns as a script and gets executed by the browser. do i have to set a request header? I tried it with the 'accepts' and 'converters' options, but didn't make it work yet. (I´m using GoogleChrome, but also happens in Safari/FF)

cheers, tom

PS: I want to get rid of the warning as this ajax request gets triggered every 2 seconds. So the console looks pretty bad...

Share Improve this question edited Sep 7, 2011 at 19:05 Jacob 78.9k24 gold badges157 silver badges241 bronze badges asked Sep 7, 2011 at 18:50 tom81tom81 111 gold badge1 silver badge2 bronze badges 1
  • Possible duplicate of: Chrome says “Resource interpreted as script but transferred with MIME type text/plain.”, what gives? – hippietrail Commented Aug 10, 2012 at 15:31
Add a ment  | 

4 Answers 4

Reset to default 4

The server should send a Content-Type header set to text/javascript when it sends the JSONP script.

CouchDB itself is sending the text/plain content-type. The only other type you can convince it to send is 'application/json' if you send 'Accept: application/json' as a header.

It seems that CouchDB should send text/javascript if delivering a jsonp response, though. If you could file a ticket I'm sure it would get done.

Problem is on target server, because it's setting Content-Type: Text/plain

You can't enforce it without access to target server. It should be Content-Type: text/javascript

Are you sending any encoding information in the headers? I had a problem with CouchDB responses and discovered that adding charset=utf-8 to my Accept or Content-Type heading resulted in CouchDB returning the text/plain content instead of the application/json I was expecting. Perhaps you can solve this by altering your header if the case is similar enough.

发布评论

评论列表(0)

  1. 暂无评论