title: how to send json data to server using ajax
body: <p>refer.jvmhost.net/refer247/registration, this is my url,i have to fetch request to this url  like user details and should get the appropriate response in <code>json</code> format with status n error if it contains  ..dont give me android code..</p>
  
  <p>this is <code>html</code> page.</p>
  
  <pre><code>&lt;head&gt;
          &lt;script type="text/javascript" src="json2.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div data-role="page" data-theme="c"&gt;
          &lt;div data-role="header" data-position="fixed" data-inset="true" class="paddingRitLft" data-theme="c"&gt;
              &lt;div data-role="content" data-inset="true"&gt; &lt;a href="index.html" data-direction="reverse"&gt;&lt;img src="images/logo_hdpi.png"/&gt;&lt;/a&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div data-role="content" data-theme="c"&gt;
              &lt;form name="form" method="post" onsubmit="return validate()"&gt;
                  &lt;div class="logInner"&gt;
                      &lt;div class="logM"&gt;Already have an account?&lt;/div&gt;
                      &lt;div class="grouped insert refb"&gt;
                          &lt;div class="ref first"&gt;
                              &lt;div class="input inputWrapper"&gt;
                                  &lt;input type="text" data-corners="false" class="inputrefer" placeholder="Userid" name="userid" id="userid" /&gt;
                              &lt;/div&gt;
                              &lt;div class="input inputWrapper"&gt;
                                  &lt;input type="password" data-corners="false" class="inputrefer" placeholder="Password" name="password" id="password" /&gt;
                              &lt;/div&gt;  &lt;a href="dash.html" rel="external" style="text-decoration: none;"&gt;&lt;input type="submit" data-inline="true" value="Submit" onclick="json2()"&gt;&lt;/a&gt;
  
                              &lt;p&gt;&lt;a href="#" style="text-decoration: none;"&gt;Forgot Password&lt;/a&gt;
  
                              &lt;/p&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;div class="logM"&gt;New user? Create refer Account&lt;/div&gt;
                      &lt;input type="button" class="btnsgreen" value="Sign Up! its FREE" class="inputrefer" data-corners="false" data-theme="c" /&gt;
              &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;p style="text-align: center;"&gt;&amp;#169; refer247 2013&lt;/p&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>this is json2.js</p>
  
  <pre><code>function json2()
      {
      var json1={"username":document.getElementById('userid').value,
                 "password":document.getElementById('password').value, 
                };
      //var parsed = jsonString.evalJSON( true );
      alert(json1["username"]);
      alert(json1["password"]);
  };
  </code></pre>
  
  <p>so tell me how to send the json data to that url n obtain some response like if email
  id is already exist if u registering with that id ..then give some error
  like email id already exist n if registerd succesfully then give respone like registerd successfully and status msg..200 okk...</p>