---
description: http://jsfiddle.net/rFzyQ/
---

# serialize, serializeObject, serializeArray (ok)

```
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://code.jquery.com/jquery.js"></script>
</head>

<body>
  <form id='postStatus'>
    <input name='somename' type='text' value='someval' />
  </form>
  <script type="text/javascript">
	  $.fn.serializeObject = function() {
	    var o = {};
	    var a = this.serializeArray();
	    $.each(a, function() {
	      if (o[this.name]) {
	        if (!o[this.name].push) {
	          o[this.name] = [o[this.name]];
	        }
	        o[this.name].push(this.value || '');
	      } else {
	        o[this.name] = this.value || '';
	      }
	    });
	    return o;
	  };
	  var v = $("#postStatus").serializeObject();
	  console.log(v);
	  console.log($("#postStatus").serialize())
	  console.log($("#postStatus").serializeArray())
  </script>
</body>

</html>
```

![](https://2726517656-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M1E4Gk2ppVKb4olmnun%2Fuploads%2FT30xyD6pK6NPaIfCordE%2FScreenshot_1.png?alt=media\&token=5ec1913e-ea02-4951-ac2f-67ff51d8fc1f)
