title: AJAX POST/GET request throws empty error but Glassfish server appears to be responding correctly
body: <p>I've setup some very simple web services on my Glassfish server using JAX-RS. Initially everything appeared to be working correctly - I'd see the expected responses through the browser (e.g. the returned HTML). Here's the code:</p>
  
  <pre><code>@GET
  @Produces("text/HTML")
  public String getHtml() {
      return "&lt;html lang=\"en\"&gt;&lt;body&gt;&lt;h1&gt;GET RESPONSE&lt;/body&gt;&lt;/h1&gt;&lt;/html&gt;";
  }
  
  @POST
  @Produces("text/HTML")
  @Consumes("text/plain")
  public String postText(String content)
  {        
      return "&lt;html lang=\"en\"&gt;&lt;body&gt;&lt;h1&gt;POST RESPONSE: " + content + "&lt;/body&gt;&lt;/h1&gt;&lt;/html&gt;";
  }
  </code></pre>
  
  <p>As you can see, it's really basic. </p>
  
  <p>The problem started though when I tried to make AJAX calls in Javascript to these web services. Both POST and GET calls fail consistently, with no useful error information. I check the response results in Firefox's Firebug plugin though and the response codes show 200 ok, though Firebug shows nothing in the HTML panel which may indicate a problem. Here's the Javascript:</p>
  
  <pre><code>$.ajax({
      type: "POST",
      url: "http://localhost:8080/TestEngine/API/",
      data: "string",
      dataType: "html",
      success: function(data, textStatus, jqXHR) {
          alert("success");
      },
      error: function(jqXHR, textStatus, errorThrown) {                             
          alert("error:" + errorThrown );
      },
      contentType: "text/plain"
  });
  </code></pre>
  
  <p>I've tried various modification and exclusions of data, dataType, contentType, etc. but they always end up throwing the error callback. I've also tried modifying the return value of the GET and POST functions, including trying to use the JAX-RS Responsebuilder (though I'm unfamiliar with it's usage, so may have done so incorrectly). I still end up in the error callback, with no apparent useful info in the error arguments (most stuff just returns as undefined or empty).</p>
  
  <p>At this point I'd really appreciate some advice as to what I'm doing wrong. Thanks!</p>