问题描述
我想用处理-JS 编写一个应用程序,而且我希望能够与服务器加载它机端的数据。我没有写在服务器端还没有,所以我可以用任何东西,但似乎显而易见的AJAX的东西是使用JSON将数据上传到页面中。
I want to write an application using processing-JS, and I'd like to be able to load it with server-side data. I haven't written the server side yet so I can use anything, but it seems the obvious AJAX thing would be to use JSON to upload the data into the page.
我怎样才能访问这些数据从我处理code?是什么东西一样容易的数据是在范围,或者可以附着到窗口对象和从处理code直接访问?
How can I get access to that data from my processing code? Is it something as easy as the data is in scope, or could be attached to the window object and directly accessed from the processing code?
更新:让这个问题我提炼一点点。我很舒服的JSON(但感谢的链接),并与写作$ C $下客户端和服务器;我真正的问题(这诚然可能是有点傻)是:如果我得到的数据,例如,JQuery的,并希望操纵它在处理-JS,它是在同一个命名空间?我需要做什么特别的访问它?
Update: Let me refine the question a little bit. I'm comfortable with JSON (but thanks for the links) and with writing code for both the client and server; my real question (which admittedly could be somewhat silly) is: if I get data with, e.g., JQuery, and want to manipulate it in processing-js, is it in the same namespace? Do I have to do anything special to access it?
推荐答案
您处理code被草率解析并转换成JavaScript。任何分析器不明白只是被忽略了,这意味着你可以自由搭配的JavaScript的code位与你的处理,它会在一般情况下,只是工作。
Your Processing code gets "sloppily" parsed and converted into JavaScript. Anything the parser doesn't understand just gets ignored, which means you can freely mix bits of JavaScript code in with your Processing and it will, in general, "just work".
看一看这里了解更多信息:http://processingjs.org/reference/articles/best-pratice
Have a look here for more information: http://processingjs.org/reference/articles/best-pratice
这篇关于从加工-JS使用JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!