title: JQuery Ajax POST throwing an empty error without making the request
body: <p>I have a function that makes an Ajax request for any anchor. The request method can be GET or POST. In this case, I want to make a POST without using a form but the Ajax request throws an error before even sending the request. The error has the value "error" and all error/failure description variables are "".</p>
  
  <pre><code> function loadPage(url,elem_id,method,data) {
      ajaxLoading(elem_id);
      $.ajax({
          type: method,
          url: url,
          data: data,
          success:function(data){
              $("#"+elem_id).html(data);;
          },
          error:function(request,textStatus,error){
              alert(error);
          }
      });
   }
  </code></pre>
  
  <p>When the function is called the params are these (copied from the js console):</p>
  
  <pre><code>data: "partial=yes"
  elem_id: "page"
  method: "post"
  url: "/projects/2/follow"
  </code></pre>
  
  <p>As asked, here is the code that calls the loadPage function.</p>
  
  <pre><code>$("body").on("click","a.ajax",function(event) {
      var _elem = getDataElem($(this));
      var _method = getRequestMethod($(this));
      var _partial = getRequestPartial($(this));
      handlers.do_request(event,$(this).attr("href"),_elem, _method, _partial);
  });
  
  var handlers = (function() {
      var obj = {};
      obj.do_request = function(event,url,elem_id,method,data) {
          event.preventDefault();
  
          loadPage(url,elem_id,method,data);
          history.pushState({selector:elem_id,method:method,data:data},null,url);
      };
  }());
  </code></pre>
  
  <p>After the failure of the Ajax request, the request is made by default and it responds sucesss. In all I have read, this seems to be a valid way to make a POST request (that doesn't need a form).</p>
  
  <p>Am I doing something wrong in the function? Why is the error information empty?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:</p>
  
  <p>I have been thinking, for a POST from a "form" that function works, when the variable "data" is made with the serialize function (e.g. "var data = $(this).serialize();"). Could it be that the format of the "data" when I make a POST without a "form" is wrong in someway? Maybe the JQuery Ajax function doesn't accept a simple string like "partial=yes" as data when a POST is made. Any thoughts on this?</p>