title: Sending and testing HTML form through JSON
body: <p>I'm working with a PHP dev and was tasked with sending an html form with 4 checkboxes as a JSON string to the server. However, whenever I click the send form button, the page is reset and I can't check if the form is being sent properly. If I add alerts or console.log to the JS code, they don't execute. I added **** to the website URL because I'd rather stay anonymous.</p>
  
  <p>The form is supposed to send the 3 strings and the 4 checkboxes through 2 different JSON links. Later I'll add validation, now I just wanted to understand why is it not executing the code. I imagine alert isn't working because the page refreshes at submit, but how can I test if it's working then?</p>
  
  <p>Thank you.</p>
  
  <p><strong>This is the JS script:</strong></p>
  
  <pre><code>    $("#form1").submit(function(e) {
          //LADO SERVIDOR (ARQUIVO PHP) https://pt.stackoverflow.com/questions/15661/receber-ajax-json-post-no-php-e-retornar-no-sucesso
          e.preventDefault();
          var identificador = $(nome      )[0].value;
          var descricao     = $(descricao )[0].value;
          var password      = $(password  )[0].value;
          $('.somename').each(function(e){
              if($(this).is(':checked'))
              list = list + $(this).attr('id')+",";
          }); 
          $.getJSON('******/get?code=3001&amp;desc='+descricao+'&amp;key='+password+'&amp;format=json&amp;charset=utf-8&amp;lang=pt_br', function(data){});
          $.getJSON('********/get?code=3004&amp;id='+identificador+'&amp;sr='+list+'&amp;format=json&amp;charset=utf-8&amp;lang=pt_br', function(data){});
          alert(list);
      });
  </code></pre>
  
  <p><strong>The HTML (using Bootstrap) part:</strong></p>
  
  <pre><code>                            &lt;div class="form-group"&gt;
                                  &lt;label&gt;Identificador do  empreendimento&lt;/label&gt;
                                  &lt;input class="form-control" placeholder="Identificador para identificar a  empreendimento" id="nome"&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Descrição do  empreendimento&lt;/label&gt;
                                  &lt;input class="form-control" placeholder="Descreva o objetivo do empreendimento" id="descricao"&gt;
                              &lt;/div&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Palavra-chave&lt;/label&gt;
                                  &lt;input class="form-control" placeholder="Palavra-chave para acessar a  empreendimento" id="password"&gt;
                              &lt;/div&gt;
  
  &lt;!--                             &lt;div class="form-group"&gt;
                                  &lt;label&gt;Static Control&lt;/label&gt;
                                  &lt;p class="form-control-static"&gt;email@example.com&lt;/p&gt;
                              &lt;/div&gt; --&gt;
                              &lt;div class="form-group"&gt;
                                  &lt;label&gt;Selecione as fontes de energia&lt;/label&gt;
                                  &lt;div class="checkbox"&gt;
                                    &lt;input class="somename" type="checkbox" id="1" value="1" name="eolica"&gt; Eolica
                                    &lt;br&gt;
                                    &lt;input class="somename" type="checkbox" id="2" value="2" name="solar"&gt; Solar
                                    &lt;br&gt;
                                    &lt;input class="somename" type="checkbox" id="3" value="3" name="biomassa"&gt; Biomassa
                                    &lt;br&gt;
                                    &lt;input class="somename" type="checkbox" id="4" value="4" name="phc"&gt; PHC
                                     &lt;br&gt;
                              &lt;/div&gt;
                              &lt;!-- &lt;a href="prevotacao.html" class="btn btn-success" role="button"&gt;Create enterprise &amp;raquo;&lt;/a&gt; --&gt;
                              &lt;button type="reset" class="btn btn-warning" id="reset"&gt;Clean form &amp;raquo;&lt;/button&gt;
                      &lt;/form&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>