Posting data over web services using Java, Ajax and json is not working <p>Could somebody help me with this. This goes always to error, no error message though, just the console.log. Is there any good way to debug this or could you just see what's wrong in this?</p> <p>Thanks! Sami </p> <pre><code>function foo(){ alert('Button pressed'); var user={"id":10,"firstName":" Ted","lastName":"TESTING","age":69,"freeText":"55555","weight":55}; $.ajax({ type: "POST", contentType: "application/json", url: "http://localhost:8080/testSoft/webresources/entity.user/", dataType: "json", data: user, success: function(data){alert(data);}, error: function(data) { console.log('#####################error:################################'+data); alert('addUser error: ' + data.firstName); } }); }; </code></pre> <p>Web service:</p> <pre><code>@POST @Override @Consumes({"application/xml", "application/json"}) public void create(User entity) { super.create(entity); } </code></pre> <p>User</p> <pre><code>public class User implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "id") private Integer id; @Size(max = 45) @Column(name = "firstName") private String firstName; @Size(max = 45) @Column(name = "lastName") private String lastName; @Column(name = "age") private Integer age; @Lob @Size(max = 65535) @Column(name = "freeText") private String freeText; @Column(name = "weight") private Integer weight; </code></pre>