jquery - Cannot POST in nodejs and mongodb on openshift -


This is my Ajax Post Request I am using Nodes and MangaDub. When I post a request, I get an error, poster croralization can not be posted in the post request. Json object I have also tried to remove the content type from the POST request and the data as JSON.stringify (currlocation) Tried to send, it still does not work

  $ .ajax ({type: "POST", Url: "http://myurl.rhcloud.com", contentType: " App / Jason ", data: curl location, datatype:" text ", success: function (feedback) {console.log (Feedback);}, error: function (error) {console.log ("error:", error);}});   

I am using nodejs and mongodb in the server.js file my configuration

  self.app.configure (function () {self.app .use (express.bodyParser ()); self.app.use (express.favicon) ()); Self.app.use (express.json ()); Self.app.use (express.urlencoded ()); Self.app.use (express.methodOverride ()); self.app.use (express .errorHandler ({dump exception: true, show stack: true}));});   

My post request in the server.js file

  self.app.post ('/', self.routes ['post']) ;; Self.routes ['post'] = function (rick, res) {console.log ("inside post"); Var promo = essential ('mangoes'); Var dbName = "/ favloc"; Var connection_string = process.env.OPENSHIFT_MONGODB_DB_USERNAME + ":" + process.env.OPENSHIFT_MONGODB_DB_PASSWORD + "@" + process.env.OPENSHIFT_MONGODB_DB_HOST + dbName; Console.log ("conncetion string" + connection_string); var db = Mongoose (connection_string, ['location']); res.setHeader ('Access-Control-Allow-Origin', '*'); Res.setHeader ('Access-Control-Permission-Practices', 'Receive, Post, Options, Put, Patch, Delete'); Res.setHeader ('access-control-permission-header', 'X-requested-with-content-type'); res.setHeader ('Access-Control-Acceptable-Credentials', Correct); db.collection ('location'). Insert ({'city': "sf", 'id': '2'}, function (result) {console.log ("success"); res.send (req.body .self); // res. end ('success');}); };    

$ ajax () is not a valid post request.

I think this actually sends the received request with the access control-request-method header set POST From

You can add support for this behavior by matching your server-side code to match.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -