Page 1 of 1

[SOLVED] dojo.hitch(...) is not a function

Posted: 13 May 2016, 18:59
by Woodruff
Hello !

This piece of code:

Code: Select all

this.ajaxcall( "/innovation/innovation/initial_meld.html", {lock: true,
		player_id: this.my_id,
		card_id: card_id});
produces this strange error into the log:

Code: Select all

Client error: TypeError: dojo.hitch(...) is not a function. During /innovation/innovation/initial_meld.html Received: {"status":1,"data":{"valid":1,"data":null}} 
I never call this function dojo.hitch anywhere in my code, so that call must be done at some point in the BGA framework.
However, that's all, this is not a blocking error, and the game flow prosecute correctly after that :lol: ...

Should I be worried, doc'?

Re: dojo.hitch(...) is not a function

Posted: 13 May 2016, 23:06
by pikiou
this.ajaxcall() requires 4 arguments and you provided 2: http://en.studio.boardgamearena.com/#!d ... amename.js
The 4th argument is a callback, the absence of which may very well be what triggers this error.

[SOLVED] dojo.hitch(...) is not a function

Posted: 14 May 2016, 12:29
by Woodruff
Thanks Pikiou!

That effectively solved the problem.
I'll add that there are two callbacks to provide:
-first to be called after server response when success,
-second to be called after server response when success or failure.

Re: dojo.hitch(...) is not a function

Posted: 14 May 2016, 21:43
by pikiou
Happy to help!
The documentation indicates that the second callback is optional so I didn't bother mentioning it, but you're right.
If this second callback is mandatory, could you fix the documentation?

[SOLVED] dojo.hitch(...) is not a function

Posted: 15 May 2016, 10:15
by Woodruff
I try to test without it, then I see :)

[SOLVED] dojo.hitch(...) is not a function

Posted: 15 May 2016, 10:32
by Woodruff
You're right, 5th argument is optional indeed. In fact, I relied on the commented pattern on the script, so I didn't notice it was optional.
So, to sum up what you said for the next one:

-Argument 1, 2 and 3 are mandatory. You pass this as the 3rd argument.
-Argument 4 is mandatory. It's a function to be called when the server call is a success. If you don't need to do anything particular, leave an empty body.
-Argument 5 is optional. It's a function to be called whatever the result or the server call is (success or failure). If you don't need that, leave an empty body or don't pass this argument at all.

Thanks a lot :D