0

How to return value from "eventCallBack" from JS method

see JS function definition:

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

Here

@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

Now I want to return value generated in "GCM_Event"

var requiredValue = window.plugins.GCM.register("428641231987", "GCM_Event", this.GCM_Success, this.GCM_Fail);

I want value in requiredValue

Joseph
  • 117,725
  • 30
  • 181
  • 234
user1924911
  • 107
  • 1
  • 1
  • 10
  • http://stackoverflow.com/questions/12475269/variable-doesnt-get-returned-from-ajax-function – Denys Séguret Mar 23 '13 at 14:46
  • Have a look at [How to return the response from an AJAX call from a function?](http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call-from-a-function) -- there is a reason why you have to pass callbacks. If the value could be returned directly, there would be no need for callbacks. – Felix Kling Mar 23 '13 at 14:47
  • It doesn't work like that. The register function you're using expects a success callback and a fail callback. Program flow should be resumed from the callbacks, and any data generated on the GCM_Event will only be available when the callbacks run (they might be asynchronous). – bfavaretto Mar 23 '13 at 15:02

0 Answers0