What is the easiest way to send a Javascript array via JSON to PHP?

Posted by dscher on Stack Overflow See other posts from Stack Overflow or by dscher
Published on 2010-04-26T23:54:54Z Indexed on 2010/04/27 0:03 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about JSON

Related posts about JavaScript