Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.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
Javascript 如何从“返回值”;“事件回调”;从JS方法_Javascript - Fatal编程技术网

Javascript 如何从“返回值”;“事件回调”;从JS方法

Javascript 如何从“返回值”;“事件回调”;从JS方法,javascript,Javascript,如何从JS方法的“eventCallBack”返回值 参见JS函数定义: window.plugins.GCM.register("428641231987", "GCM_Event", this.GCM_Success, this.GCM_Fail); 这里 现在我想返回在“GCM_事件”中生成的值 我想要requiredValue中的值看看——这是您必须传递回调的原因。如果该值可以直接返回,那么就不需要回调。它不是这样工作的。您正在使用的register函数需要成功回调和失败回调。程序流应

如何从JS方法的“eventCallBack”返回值

参见JS函数定义:

window.plugins.GCM.register("428641231987", "GCM_Event", this.GCM_Success, this.GCM_Fail);
这里

现在我想返回在“GCM_事件”中生成的值


我想要requiredValue中的值看看——这是您必须传递回调的原因。如果该值可以直接返回,那么就不需要回调。它不是这样工作的。您正在使用的register函数需要成功回调和失败回调。程序流应该从回调中恢复,在GCM_事件上生成的任何数据只有在回调运行时才可用(它们可能是异步的)。
@param senderId - GCM service identifier

@param eventCallback - {String} - Name of global window function that will handle incoming events from GCM
@param successCallback - {Function} - called on success on registering device

@param failureCallback - {Function} - called on failure on registering device
var requiredValue = window.plugins.GCM.register("428641231987", "GCM_Event", this.GCM_Success, this.GCM_Fail);