Tutorial :Is there a JavaScript function to serialize and unserialize arrays like PHP?



Question:

I'm making a PHP model to store a serialized array in a database. The array is then accessed via AJAX through an HTTP request.

Is there a JavaScript function to serialize and unserialize arrays like PHP?

EDIT: This is the php function http://uk.php.net/manual/en/function.serialize.php


Solution:1

Sorry for the (almost an year :) ) late response, but i just saw this.

Since i can only place one link, i will give you this one: http://phpjs.org/functions/index

Search for "serialize" and "unserialize" and you'll find them. I had to send serialized data to the server, and PHP works perfectly with the results of these functions.

Be sure to also take a look at the dependencies and get those functions as well.

Best of luck!


Solution:2

You meant “serialize”? jQuery’s $.ajax & $.json methods would automatically serialize JavaScript objects for you, and in modern browsers you can use JSON.stringify directly.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »