Javascript 主干提取产生404错误
我尝试使用以下主干模型节点从服务器获取数据,但在出现404错误的那一刻,我检查了我的文件,它们似乎是正确的Javascript 主干提取产生404错误,javascript,node.js,backbone.js,express,Javascript,Node.js,Backbone.js,Express,我尝试使用以下主干模型节点从服务器获取数据,但在出现404错误的那一刻,我检查了我的文件,它们似乎是正确的 var app = app || {}; app.NotesModel = Backbone.Model.extend({ url:'/usernotes', defaults: { username:'', email:'', about:'', editorNote:''
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根本不会给我任何输出 是一个类似的问题
试试这个:
app.NotesModel.fetch({data: $.param({email: email}) });
或者这个:
app.NotesModel.fetch({data: {email: email}, processData: true });
向我们展示您的server.js/index.js以及如何使用路由文件。代码的最后一部分是我的index.js文件的内容。另外,如果有帮助的话,我的项目是基于drywalljs的。最后,我使用了一个例程.js文件,其中包含了在您显示路由文件的代码段的中间所提到的路径,但是在您的索引文件中,您不需要在什么地方执行类似于App.UsSeriRe'Trase.jsApp;?Bazinga777在浏览器控制台网络日志中检查获取模型时调用的地址。对吗?我来试一试并更新一下