Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to save Backbone JSONP model to MongoDB using Node/Express?
    text
    copied!<p>I need a way to parse my JSONP object on server side to save it, due to cross domain origin issue I have shifted my way of communication from JSON to JSONP but not finding any suitable way to parse JSONP on server side to save it to the database.</p> <p>Following is the Model,</p> <pre><code>define(['backbone'],function(Backbone){ 'use strict'; return Backbone.Model.extend({ url:"http://crossdomain:9847/page", defaults: { type:'text', position:0, align:'left', text:{"en":""}, color:"#000", weight:'normal', size:"14px", font:"Verdana", pageid:'askdkasdkgaskdgks' }, idAttribute:'_id', sync: function(method, collections, options) { options.dataType = "jsonp"; return Backbone.sync(method, collections, options); } }); }); </code></pre> <p>Express Server,</p> <pre><code>var express = require('/root/node_modules/express'); var page = require('./routes/page.js'); var app = express(); app.configure(function () { app.use(express.json()); app.use(express.urlencoded()); app.set("jsonp callback", true); }) app.get('/page', page.updatePage); app.listen(9847); exports.updatePage = function(req, res) { console.log(req.query); // Here how I can parse the req is my problem // so I can save object to database? } </code></pre> <p>URL is generating like,</p> <pre><code>http://crossdomain:9847/page?callback=jQuery203010156283635587138_1384408493698&amp;{%22text%22:{%22en%22:%22Text%22},%22type%22:%22text%22,%22position%22:0,%22align%22:%22left%22,%22color%22:%22#000%22,%22weight%22:%22normal%22,%22size%22:%2214px%22,%22font%22:%22Verdana%22,%22pageid%22:%22askdkasdkgaskdgks%22}&amp;_=1384408493700 </code></pre> <p>and I am able to receive,</p> <pre><code>{ callback: 'jQuery203010156283635587138_1384408493698', '{"text":{"en":"Text"},"type":"text","position":0,"align":"left","color":"': '' } </code></pre> <p>Now how can I parse this ? I can get callback from callback parameter, but how to get actual data ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload