Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
meteor.call不从meteor.method调用方法_Meteor - Fatal编程技术网

meteor.call不从meteor.method调用方法

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

我对回调方法有问题

我已经在服务器文件夹中的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.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()不是服务器上的函数。