This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Spring MVC REST POST call is giving 400 with JQuery ajax call

Apr 2nd, 2013, 01:13 PM

I am trying to call my spring MVC REST service and it works with a JQuery $.post but not $.ajax.
The javascript shows this 400 error;
1. Failed to load resource: the server responded with a status of 400 (Bad Request) https://s3.amazonaws.com/codiqa-cdn/jquery-1.7.2.min.js
1. sendjquery-1.7.2.min.js:4
2. f.extend.ajaxjquery-1.7.2.min.js:4
3. logIntoCMS:8080/coco/:124
4. onclick

The only real difference is I need it to be synchronous to wait on user data so I need $.ajax with async:false. It looks like the data line is wrong in the ajax call. The data comes from an input field and select box both with the IDs above. Every combination I've tried doesn't work.

Ok, I figured this out. Spring is giving a good error. JQuery is sending data. It may not look wrong in a javascript debugger, but it is improperly formatted or something. Remove dataType and contentType. The data now needs to be the format;