limlim
limlim

Reputation: 405

Cant get view to render

I am developing an application with node.js, express, couchDB and using nano to communicate with couch. I am using a jquery get request from client javascript. Using fiddler i can see that i get my view in the RAW result but the view is never rendered.

client:

$.get('employee/'+customerId, function(data){
        return;
    });

route:

app.get('/employee/:id', employee.viewEmployee);

viewEmployee:

exports.viewEmployee = function(req, res){
    db.get(req.params['id'], { revs_info: false }, function(err, body, header) {
        res.render('employee/single', {employee: body});
    });
};

Everything works with no errors and i get the 'employee/single' view html in the raw response. my question is why the view is not rendered? why is the html just sent back in the raw and how can i get this to work?

Upvotes: 0

Views: 133

Answers (2)

Erin
Erin

Reputation: 2427

Your $.get call is using a call back that isn't doing any thing.

from the jQuery api examples

$.get("test.php",
   function(data){
     $('body').append( "Name: " + data.name ) // John
              .append( "Time: " + data.time ); //  2pm
   }, "json");

Shows you how to do this.

Upvotes: 2

chovy
chovy

Reputation: 75864

You are doing an ajax call.

try console.log(data) inside your $.get callback, are you seeing the html you expect?

Upvotes: 0

Related Questions