Backbone fetch产生404错误

时间:2014-09-18 19:35:29

标签: javascript node.js backbone.js express

我有以下主干模型节点,我试图用来从服务器获取数据,但目前我收到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()根本不会给我任何输出。

1 个答案:

答案 0 :(得分:0)

Here是一个类似的问题。

试试这个:

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

或者这个:

app.NotesModel.fetch({data: {email: email}, processData: true });
相关问题