I have an ajax get request as shown below. I am making a GET request to server.js in openshift using nodejs express. However, I get html content in the response method instead of the json object. Both requests belong to the same domain. The node modules I use are moongojs, mongodb and bson.
$.ajax({
type: "GET",
url: "http://abc-favspot.rhcloud.com",
contentType: "application/json",
data: JSON.stringify(currLocation),
dataType: "text",
success: function(response){
callback(response);
},
error: function( error ){
console.log( "ERROR:", error );
}
});
In my server.js file there is the following code
self.routes['getData'] = function(req, res){
console.log("gat method");
self.db.collection('location').find().toArray(function(err, names) {
res.header("Content-Type:","application/json");
console.log("success get");
res.send(names);
});
};
source
share