title: Calling Ajax request function in href
body: <p>I have an href in an html page and i have an AJAX request in a method in a javascript file. </p>
  
  <p>When clicking on href i want to call the JS function and I am treating the response to add it to the second html page which will appear</p>
  
  <pre><code>function miniReport(){
  
      alert('TEST');
  
     var client_account_number = localStorage.getItem("numb");
  
     var request = $.ajax({
          url: server_url + '/ws_report',
          timeout:30000,
          type: "POST",
          data: {client_language: client_language, PIN_code:pin,client_phone:number}
      });
      request.done(function(msg) {
          //alert(JSON.stringify(msg));
  
      });
      if (msg.ws_resultat.result_ok==true)
      {
          alert('success!');
          window.open("account_details.html");
  
      }
  
      request.error(function(jqXHR, textStatus)
      {
         //MESSAGE
      });
  
  }
  </code></pre>
  
  <p>I tried with <code>&lt;a href="#" onclick="miniReport()"&gt;&lt;/a&gt;</code>, and also to write the function with <code>$('#idOfHref').click(function(){});</code> not working. </p>
  
  <p>All I can see is the alert TEST and then nothing happens. I checked several posts here but nothing works for me.</p>