Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - Unserialize a Serialized String

In jQuery is there a way to take a serialized string, that was serialized by jQuery, and unserialize the string and place the values into a form in the right location (ie. insert text into input fields and text fields check the correct checkboxes and radio buttons and choose the correct select option). Or will I need to make a script that will plug in the values for the fiels directly?

like image 761
Lee Avatar asked May 04 '12 17:05

Lee


People also ask

What is the use of serialize () method in jQuery?

The serialize() method creates a URL encoded text string by serializing form values. You can select one or more form elements (like input and/or text area), or the form element itself. The serialized values can be used in the URL query string when making an AJAX request.

How can I access serialized form data in PHP?

To get the POST values from serializeArray in PHP, use the serializeArray() method. The serializeArray( ) method serializes all forms and form elements like the . serialize() method but returns a JSON data structure for you to work with.

How do you serialize form data?

To serialize a FormData object into a query string, pass it into the new URLSearchParams() constructor. This will create a URLSearchParams object of encoded query string values. Then, call the URLSearchParams. toString() method on it to convert it into a query string.

How do you serialize data in JavaScript?

In JavaScript, for example, you can serialize an object to a JSON string by calling the function JSON. stringify() . CSS values are serialized by calling the function CSSStyleDeclaration. getPropertyValue() .


1 Answers

I ended up finding a jQuery plugin that did the trick:

https://github.com/kflorence/jquery-deserialize

All I had to do was include the file and call the function, it took care of the rest.

like image 78
Lee Avatar answered Oct 13 '22 11:10

Lee