Try converting the HTML form to JSON but return empty


I've been trying to convert an HTML form into Json. When I submit the form my alert is just returning an empty array. Any help is greatly appreciated!

Here is the form

<form action="" method="post" name="myForm">
Code (xxxx-xxx):<input type="text" name="drugcode" /> <br/>
<p><input type="submit" onClick='submitform()' /></p>

And here is the javascript

<script src=""></script>

<script language ="javascript" type = "text/javascript" >

function submitform() {

var formData = JSON.stringify($("form[name*='myForm']").serializeArray());

  type: "POST",
  url: "serverUrl",
  data: formData,
  success: function(){},
  dataType: "json",
  contentType : "application/json",
 processData: false


All that this is returning is:


EDIT: It now returns:


how would I would I have it return: {"code":"1234","value":"4321"}

$("#myForm") is not going to match the form for you. # specifies an id. You need to match on the name:

$( "form[name='myForm']" )...