Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addItem(){
- var array =
- [
- {"quantidade":"1","valorUnd":10,"produto":
- {"id":"1","grades":[{"propriedade":{"id":"2"},"classe":{"id":"1"}}]}
- },
- {"quantidade":"1","valorUnd":10,"produto":
- {"id":"2","grades":[{"propriedade":{"id":"3"},"classe":{"id":"2"}}]}
- },
- {"quantidade":"1","valorUnd":10,"produto":
- {"id":"3","grades":[{"propriedade":{"id":"4"},"classe":{"id":"3"}}]}
- }
- ];
- array = JSON.stringify(array);
- $.ajax({
- headers: {
- 'Content-Type': 'application/json',
- 'dataType' : 'json'
- },
- type: "POST",
- url : 'addItem',
- data : array,
- success : function(result) {
- document.formulario.submit();
- },
- error: function (jqXHR, textStatus, msg) {
- alert(msg);
- }
- });
- }
- @RequestMapping(value = "addItem", method = RequestMethod.POST)
- public @ResponseBody
- void addItem(@RequestBody ItemEntrada[] array,HttpServletRequest request) {
- /*
- * ações do metodo
- */
- }
- }
- var array =
- [
- {"quantidade":"1","valorUnd":10,"produto":
- {"id":"1","grades":[{"propriedade":{"id":"2"},"classe":{"id":"1"}}]}
- }
- ];
- var array =
- [
- {"quantidade":"1","valorUnd":10,"produto":
- {"id":"1"}
- },
- {"quantidade":"1","valorUnd":10,"produto":
- {"id":"2"}
- },
- {"quantidade":"1","valorUnd":10,"produto":
- {"id":"3"}
- }
- ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement