[SERVER-8977] Simple REST Interface --JSONP sending wrong MIME type Created: 14/Mar/13  Updated: 07/Jul/17  Resolved: 07/Jul/17

Status: Closed
Project: Core Server
Component/s: HTTP Console
Affects Version/s: 2.2.1
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Craig Vitter Assignee: DO NOT USE - Backlog - Platform Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Running on MacOS 10.7.5 - problem not verified on other platforms


Operating System: OS X
Steps To Reproduce:

Start server with: mongod --rest --jsonp
Make JSONP call with JQuery
Review error message

Participants:

 Description   

I am having a play with the Simple REST Interface via "mongod --rest --jsonp" and have run into the following error when making calls with JQquery:

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

The JQuery I am using is pretty standard:

$.ajax({
type: 'GET',
url: queryUrl,
async: true,
contentType: "application/json",
dataType: 'jsonp',
jsonp: 'jsonp',
success: function(msg) {
if (msg.response != null && msg.response.success == true)

{ $("textarea#queryResult").val(JSON.stringify( msg.data, null, '\t' )); }

},
error: function(jqXHR, textStatus, errorThrown)

{ $("textarea#queryResult").val("Error: " + textStatus + " " + errorThrown); }

});



 Comments   
Comment by Zak [ 25/Apr/13 ]

Hi,

Are you pulling the data from mongo directly or are you making the request to a webserver. In that case you should probably try this jquery library for JSONP requests. You can download it from this link:

https://github.com/jaubourg/jquery-jsonp/blob/master/doc/API.md

Generated at Thu Feb 08 03:18:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.