5

How to iterate below serialized data using jQuery

a:2:{i:0;s:8:"member 1";i:1;s:8:"member 2";}
2
  • 1
    The data you've shown isn't serialised at all - it's just an object (although with syntax problems due to the ;). Assuming you have actual JSON data, then you can just use JSON.parse to turn it back in to an object Commented Aug 4, 2016 at 7:12
  • Possible duplicate of Unserialize PHP Array in Javascript Commented Aug 4, 2016 at 9:10

1 Answer 1

0

If you fetch serialized object using PHP, Why do you need php serialized object unserialize through jQuery only.

you can simply convert it into json serialize in PHP

ob_clean();
echo json_encode(unserialize($serialized_string));
die();

In jQuery you can use AJAX dataType when the response is not set as JSON

var obj= JSON.parse(response_from_server);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.