2014-09-18 41 views
0

我试图用来从服务器提取数据的骨干模型节点,但此刻我收到404错误,我检查了我的文件,他们似乎是正确的产生404错误的骨干提取

var app = app || {}; 

app.NotesModel = Backbone.Model.extend({ 
    url:'/usernotes', 
    defaults: {    
     username:'', 
     email:'', 
     about:'', 
     editorNote:'' 
    } 
}); 


app.NotesView = Backbone.View.extend({ 
    el:'#notes', 
    events: { 
     'click #save': 'save' 
    }, 
    template1: _.template($('#about').html()), 
    template2: _.template($('#facts').html()), 

    initialize: function() {    
     app.NotesModel = new app.NotesModel({});  

     var email = $('#data-user').text();   

     app.NotesModel.fetch({data: {email: email},type:'GET' }); 

     this.render(); 
    }, 
    render: function() { 

    }, 

这就是路由文件看起来像

app.get('/account/usernotes/', require('./views/account/usernotes/index').init); 
app.get('/account/usernotes/:email', require('./views/account/usernotes/index').find); 

和功能的路由

'use strict'; 

exports.init = function(req, res){ 
    if (req.isAuthenticated()) { 
    //console.log(req.user.email); 

    res.render('account/usernotes', 
     { data : { 
      user : req.user.email 
     } 
    }); 
    } 
    else { 
    res.render('signup/index', { 
     oauthMessage: '', 
     oauthTwitter: !!req.app.config.oauth.twitter.key,  
     oauthFacebook: !!req.app.config.oauth.facebook.key, 
     oauthGoogle: !!req.app.config.oauth.google.key 
    }); 
    } 
}; 

exports.find = function(req,res) { 
    console.log('here'); 
    console.log(JSON.stringify(req)); 
} 

做console.log()根本没有给我任何输出。

+0

向我们展示你的'server.js' /'index.js'和你如何使用你的路由文件。 – Jordonias 2014-09-18 19:41:46

+0

代码的最后部分是我的index.js文件的内容。此外,如果有帮助,我的项目基于drywalljs。最后,我在代码 – Bazinga777 2014-09-18 19:42:48

+0

中使用routes.js文件,并显示你的'routes'文件,但没有说明在你的'index.js'中你需要做些什么, app.use(要求( 'routes.js')(APP));'? – Jordonias 2014-09-18 19:47:37

回答

0

Here是一个类似的问题。

试试这个:

app.NotesModel.fetch({data: $.param({email: email}) }); 

或本:

app.NotesModel.fetch({data: {email: email}, processData: true });