Jquery serialized value unserialize in php

on with Leave a reply

We normally have to serialize the form to post the form data to Ajax controller. Jquery serialize will serialize the form data, so it will be like query string. Using $.post or $.get we can call the Ajax server. So here we will send the form data in serialized format.

rsz_1jquery-serialize

How to get the jquery serialized data in php

It’s very normal, depends on ajax method (Post, Get) we will get the value $_POST[‘data’] or $_GET[‘data’]. Now we have data something similar to this.

$param = 'str1=value1&str2=value2';

How to extract the jquery serialized string in php

parse_str php function will parse the string into variables. So parse_str will help us extract the serialized string.

example:-

$param = 'str1=value1&str2=value2';
parse_str($param);  

print $str1; //value1
print $str2; //value2

Cheers 🙂

Posted in jQuery, PHP and tagged , by .

About Gowri

I am professional web developer with 4+ years experience. PHP, jQuery, WordPress, Magento and Symfony2 are my key skills in web development. I am working with strong enthusiastic team with spirit. We provide all web related solution like HTML/CSS development, Web graphic design and Logo.

Leave a Reply

Your email address will not be published. Required fields are marked *