title: HTTP Status 415 - Unsupported Media Type for AJAX call in JQUERY to Restful WS implemented with JERSEY
body: <p>Hi I am trying to post json data to Restful WS implemented with Jersey. I am posting data through jquery-ajax. Why am I geting HTTP Status-415 unsupported Media type? Thank you.<br>
  <a href="http://i.stack.imgur.com/9Sj7S.png" rel="noreferrer">Click here for screenshot of firebug description</a></p>
  
  <pre><code> //post method handler 
        @Path("/newentry")
          public class NewEntry {
  
              @POST
              @Consumes(MediaType.APPLICATION_JSON)
              public Response newEntry(String data) {
                      //doStuff
          }
      }
      // ajax call 
           $.ajax({
                   url: "http://localhost:8080/FirstRestWebService/rest/newentry",
                   type: "post",
                   data: formToJSON(),
                   dataType : "json",
                   success: function(data){
                  alert("success");
                    },
                 error:function(jqXHR, textStatus, errorThrown) {
                      alert("failure");
                    }   
              }); 
  
           function formToJSON() {
                  return JSON.stringify({
                      "name": $("input#emp_name").val(),
                      ...
                      "username": $('input#username').val(),
                      "password": $('input#password').val()
                      }); 
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/9Sj7S.png" rel="noreferrer">Click here for screenshot of firebug description</a>
  <strong>I was able to test the WS successfully by Jersey Client</strong>. What is wrong in the above AJAX call? Thank you.</p>