是否可以从 processingjs 传递变量 Javascript/jQuery 用于 AJAX 发送到服务器
最佳答案
当然有可能。有很多方法,其中一种方法是将您希望传递的变量附加到 window
对象。这不是唯一的解决方案,也绝对不是最优雅的解决方案,但是它确实有效。
所以像这样:
// processingjs code...
window.varIWantToPassAround = "whatever";
// jQuery code...
// as long as you don't redefine the variable "varIWantToPassAround", you can reference it without referencing the window object. IE "window.varIWantToPassAround"
// but I like to be explicit so when I read my code 3 months later and go "where did *that* come from, I can see it is attached to the window object.
$("#unicorn_powerd_div").someFunctionThatGrowsMagicUnicorns(window.varIWantToPassAround);
关于Javascript 或 jQuery 获取Processingjs 变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4242799/