js warning: Resource interpreted as Script but transferred with MIME type text/plain
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开发者_JAVA百科 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...
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.
精彩评论