Express Response an Ajax Get Taking over Page, not binding data

30 views
Skip to first unread message

A

unread,
Jul 1, 2015, 11:28:05 PM7/1/15
to expre...@googlegroups.com
HI,

I have a page that is requesting data via ajax as such

....
url 
= 'hello/world/123',
method
: 'get',
...


The route is this
app.get('/hello/world/:num', function(req, res) {hello.readWorld(req, res, req.params.num)});



Which successfully calls this
module.exports.readWorld= function (req, res, num) {
    world
.findById(num, {'_id': 0,'Stuff' : 1}, function (err, results) {        
        
if (err) res.send(err);          
        res
.type('json');
        res
.json({"data":results});
        
//res.send(results);
    
});
}


The above works, i get all the correct JSON

The problem is it overwrites my whole page (as in all I see is the JSON) vs binding it to the call

I tried res.send(results) and a few other variations with no luck

Thanks

A

unread,
Jul 1, 2015, 11:38:17 PM7/1/15
to expre...@googlegroups.com
Forgot to mention, if it matters, that it is a JQuery operation

Jishnu Viswanath

unread,
Jul 2, 2015, 2:11:03 AM7/2/15
to expre...@googlegroups.com
It has nothing to do with express js. You are doing something wrong with response you get. Ask in stackoverflow with front end code you will get answer there.

Jishnu Viswanath
Software Engineer
Scienaptic Systems

--
You received this message because you are subscribed to the Google Groups "Express" group.
To unsubscribe from this group and stop receiving emails from it, send an email to express-js+...@googlegroups.com.
To post to this group, send email to expre...@googlegroups.com.
Visit this group at http://groups.google.com/group/express-js.
For more options, visit https://groups.google.com/d/optout.

A

unread,
Jul 2, 2015, 11:59:22 AM7/2/15
to expre...@googlegroups.com
Will try, thanks
Reply all
Reply to author
Forward
0 new messages