What is the easiest way to send a Javascript array via JSON to PHP?
- by dscher
I have a few arrays that I want to send to process with PHP. Using json2.js I will stringify the arrays like so:
var JSONlinks = JSON.stringify(link_array);
var JSONnotes = JSON.stringify(note_array);
but then I'm confused. Do I need to use a XMLHttpRequest object? Is there another way? If that is the simplest way, could someone please just share the most basic instance of the code needed in order to send to PHP where I can then use JSON decode? I think it might help others in the future really.
I'm currently using Jquery and I know there are many options out there for frameworks and each one may or may not make this process any easier. If you're using a framework in your reply please mention why you'd choose that framework rather than just javascript.