Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using JSON from Processing-JS

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.

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?

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?

like image 566
Charlie Martin Avatar asked Aug 03 '26 11:08

Charlie Martin


1 Answers

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".

Have a look here for more information: http://processingjs.org/reference/articles/best-pratice

like image 165
j4mie Avatar answered Aug 05 '26 07:08

j4mie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!