Here's the same thing, but with a check to make sure the callback exists. Also I'm not sure why you're using the call() method. You can just call the function directly:
I know this topic is a bit older, but I was having the same problem with json_encode and javascript functions. After a little searching, I found this solution: