title: html how to send user field input as a json object
body: <p>I am having a form in which two input's are defined username and password, but i want to send this input as a json object to server, here is my html form</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;form name="MY Form" action="Login" method="post"&gt;
  
          userid&lt;input type="text" name="username" id="username"&gt; &lt;br&gt;
          password&lt;input type="password" name="password" id="password"&gt;
          &lt;br&gt; &lt;input type="submit" name="button1" value="login"&gt; 
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>now how can i send this data as a json object, i have searched that i can use jquery or ajax but i am finding difficult to implement it, can anyone please tell me how can i send it as a json.</p>