hi all I have a code like this
var BaseController = require("./Base"),
View = require("../views/Base"),
model = new (require("../models/ContentModel"));
module.exports = BaseController.extend({
name: "insertUser",
content: null,
run: function(req, res, next) {
model.setDB(req.db);
var self = this;
req.body = _.omit(req.body, '__proto__');
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(req.body));
/*this.getContent(function() {
// var v = new View(res, 'place');
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify(self.content));
});*/
// console.log("go to hell");
},
but it is sending me response in this FORMAT
{"{\"code\":\"Øù4\n\u0013¦é\",\"Age\":25}":"","proto":{}}
I just want remove "proto":{} or specifically to sal I want to get the output like this
"{\"code\":\"Øù4\\n\\u0013¦é\",\"Age\":25}"
will you guys please check where I am making the bug or the error
well,I am send the ajax request to the controller by this process
function encryptCode()
{
var value = document.getElementById("code").value;
var key = "secretKeyToProvide"; /*--Provide Your secret key here--*/
var codeValue = rc4(key, value);
var arr = {code:codeValue, Age:25};
var request =
$.ajax({
url: "http://localhost:3000/insertUser",
type: "POST",
data: JSON.stringify(arr),
dataType: 'json',
async: false,
contentType: "application/x-www-form-urlencoded", //This is what made the difference.
});
request.success(function(result) {
var value = JSON.stringify(result);
alert(value);
});
request.fail(function(jqXHR, textStatus) {
alert("Request failed: " + textStatus);
});
}
how to get rid of this "proto"