meteor.call不从meteor.method调用方法
我对回调方法有问题 我已经在服务器文件夹中的methods.js上创建了 和client/test/mytest文件夹中的一个callback.js文件 mycallback.js包含以下代码meteor.call不从meteor.method调用方法,meteor,Meteor,我对回调方法有问题 我已经在服务器文件夹中的methods.js上创建了 和client/test/mytest文件夹中的一个callback.js文件 mycallback.js包含以下代码 Template.testHello.events({ "click #testHello": function(e) { Meteor.call("testmethod",function(error, id) { if (error) { Errors.thro
Template.testHello.events({
"click #testHello": function(e) {
Meteor.call("testmethod",function(error, id) {
if (error) {
Errors.throwError(error.reason);
}
return false;
});
return false;
}
});
js文件代码是
Meteor.methods({
testmethod: function(att) {
alert("hello testmethod..");
}
});
但当我点击按钮“testHello”时,它会给我类似“InternalServerError500”的错误
有人知道这件事吗
谢谢,仅使用客户端方法调用没有任何意义,因为Meteor方法旨在在服务器上执行RMI(远程方法调用) 如果希望您的方法在客户端上具有模拟副本,请将
methods.js
移动到server/methods.js
或lib/methods.js
编辑:
正如@user728291所暗示的,
alert
方法是在窗口
对象上定义的,该对象是一个与浏览器相关的对象,因此只能在客户端环境中使用,您可以使用console.log
在服务器上打印内容。ok,我已经将methods.js移到了服务器/文件夹,但它仍然给出了相同的错误。我认为您现在得到了不同的错误,alert()不是服务器上的函数。