1

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...

Jacob
  • 72,750
  • 22
  • 137
  • 214
tom81
  • 11
  • 1
  • 1
  • 2
  • Possible duplicate of: **[Chrome says “Resource interpreted as script but transferred with MIME type text/plain.”, what gives?](http://stackoverflow.com/questions/3467404/chrome-says-resource-interpreted-as-script-but-transferred-with-mime-type-text)** – hippietrail Aug 10 '12 at 15:31

4 Answers4

4

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

Jacob
  • 72,750
  • 22
  • 137
  • 214
  • Thanks. But it is on cloudant, which always sends "text/plain". I wasn't able change the Content-Type. Is it also possible to accept different Content-Types on the client? Or does anyone know if it is possible to change it on cloudant? – tom81 Sep 07 '11 at 19:02
  • 1
    You'd be doing a lot of people a favor if you reported this as a bug to the cloudant developers. This is probably a case where you're best served waiting for a fix from them. – Jacob Sep 07 '11 at 19:07
1

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.

Robert Newson
  • 4,541
  • 16
  • 18
  • this was raised as https://issues.apache.org/jira/browse/COUCHDB-1274 since it's an issue in core CouchDB. Probably resolve it in the morning. – Robert Newson Sep 07 '11 at 20:55
0

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.

Steve Benner
  • 1,623
  • 20
  • 26
0

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

genesis
  • 48,512
  • 18
  • 91
  • 118