title: ajax call doesn't work when a submit button is used
body: <p>I'm trying fetch a live currency rate using the following API.</p>
  
  <pre><code>"http://www.exchangerate-api.com/INR/USD/1?k=FQRxs-xT2tk-NExQj"
  </code></pre>
  
  <p>When I click on a button, it alerts the rate and works just fine. I'm using the following  Ajax code.</p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
      function testCurrencyRate()
      {
          $.ajax({
                  datatype:"html",
                  type: "GET",
                  url: "ajax/LiveCurrencyRate.php",
                  data: "t="+new Date().getTime(),
                  success: function(response)
                  {       
                      alert(response);                    
                  },
                  error: function(e)
                  {
                      alert('Error while fetchig the live currency rate.');                       
                  }
              }); 
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>The Ajax request goes to the <code>LiveCurrencyRate.php</code> page which is as follows. </p>
  
  <pre><code>$url="http://www.exchangerate-api.com/INR/USD/1?k=FQRxs-xT2tk-NExQj";               
  $result = file_get_contents($url);
  echo $result;   
  </code></pre>
  
  <p>and the <code>&lt;form&gt;&lt;/form&gt;</code> which contains the only button which when clicked makes an Ajax request on this URL <code>ajax/LiveCurrencyRate.php</code>. </p>
  
  <pre><code>&lt;form id="testForm" name="testForm" action="" method="post"&gt;    
      &lt;input type="submit" id="btnTestCurrencyRate" name="btnTestCurrencyRate" value="Test" onclick="testCurrencyRate();"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Everything is fine. The problem however arises when I change the button type from <code>type="button"</code> to <code>type="submit"</code>, it doesn't work. The alert box in the error part of the Ajax function <strong>shows the alert box just for a while and all of a sudden it disappears</strong>. I can't find any reasonable cause that may prevent this request from being completed. The same thing worked for me in my previous project but I was using <code>XMLHttpRequest</code> for making Ajax requests. What's going wrong here?</p>