title: ajax XHR failed loading: POST
body: <p>so I am trying to post with ajax, and it just wont go through.</p>
  
  <p>here is my javascript</p>
  
  <pre><code>$.fn.serializeObject = function()
          {
              var o = {};
              var a = this.serializeArray();
              $.each(a, function() {
                  if (o[this.name] !== undefined) {
                      if (!o[this.name].push) {
                          o[this.name] = [o[this.name]];
                      }
                      o[this.name].push(this.value || '');
                  } else {
                      o[this.name] = this.value || '';
                  }
              });
              return o;
          };
  
          $(function() {
              $('#formulario').submit(function() {
                  formData = JSON.stringify($('#formulario').serializeObject());
                  console.log(formData);
                  //return false;
  
                                      $.ajax({
                type: "POST",
                url: "http://localhost/teleinformatica/API/user/validarLogin",
                data: formData,
                success: function(data){console.log(data.msg);},
                error: function(){location.reload();},
                dataType: "json",
                contentType : "application/json"
              });
  
  
              });
          });
  </code></pre>
  
  <p>I am not getting an error nor am I getting a success from ajax. But I am getting a chrome console error listed above XHR failed loading: POST</p>
  
  <p>sometimes the post is done correctly, and others i get XHR failed loading: POST</p>
  
  <p>This is the error</p>
  
  <pre><code>XHR failed loading: POST 
  "http://localhost/teleinformatica/API/user/validarLogin".
     send @ script/jquery.min.js:2
     ajax @ script/jquery.min.js:2
     (anonymous function) @ p2.php:89
     dispatch @ script/jquery.min.js:2
     u @ script/jquery.min.js:2
  </code></pre>
  
  <p>Any help on this matter really appreciated.</p>