title: preventing form auto submit ajax laravel
body: <p>I have fetched the data from <code>database</code> using <code>ajax</code> and i am  showing it to the user using javascript <code>confirm</code> dialog. But even after user selects <code>cancel</code> option, <code>form</code> is being submitted, but I want to submit a form only when user wants to proceed further by selecting <code>OK</code> in confirm box. Here is my <code>code</code></p>
  
  <pre><code>     &lt;form class="form-horizontal form-bordered" method="post" id="ncell" action="formaction"&gt;
             &lt;input type="hidden" name="_token" value="{{csrf_token()}}"&gt;
  
               &lt;div class="form-group"&gt;
                  &lt;label class="col-md-3 control-label" for="inputSuccess"&gt;Amount&lt;/label&gt;
                       &lt;div class="col-md-6"&gt;
                           &lt;select class="form-control mb-md" name="amount" id="amount"&gt;
                                   &lt;option value="10"&gt;10&lt;/option&gt;
                                   &lt;option value="20"&gt;20&lt;/option&gt;
                                   &lt;option value="30"&gt;30&lt;/option&gt;
                                   &lt;option value="40"&gt;40&lt;/option&gt;
                                   &lt;option value="50"&gt;50&lt;/option&gt;
                            &lt;/select&gt;
  
                    &lt;/div&gt;
                 &lt;/div&gt;
  
      &lt;div class="input-group mb-md"&gt;                  
      &lt;button type="submit" class="btn btn-warning btn-sm" id="sub"&gt;Submit&lt;/button&gt;
       &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and my <code>javascript</code></p>
  
  <pre><code>&lt;script&gt;
      $("#ncell").submit(function(e){
          var selectedVal= $("select option:selected").val();
          $.ajax({
              type:"GET",
              url: "/getdollarvalue",//put y
              data:{ value:selectedVal},
              contentType: "application/json; charset=utf-8",
              dataType: "Json",
              success: function(result){
                  return confirm(result.nrs); // Note Send the Json Object from the server side
              }
  
          });
          e.preventDefault();
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>I am now getting the confirm dialog when user clicks the <code>submit</code> button. I just want to proceed further only when user clicks <code>OK</code> in <code>confirm</code> dialog.</p>