Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. function addItem(){
  2.  
  3. var array =
  4. [
  5. {"quantidade":"1","valorUnd":10,"produto":
  6. {"id":"1","grades":[{"propriedade":{"id":"2"},"classe":{"id":"1"}}]}
  7. },
  8. {"quantidade":"1","valorUnd":10,"produto":
  9. {"id":"2","grades":[{"propriedade":{"id":"3"},"classe":{"id":"2"}}]}
  10. },
  11. {"quantidade":"1","valorUnd":10,"produto":
  12. {"id":"3","grades":[{"propriedade":{"id":"4"},"classe":{"id":"3"}}]}
  13. }
  14. ];
  15.  
  16. array = JSON.stringify(array);
  17.  
  18. $.ajax({
  19. headers: {
  20. 'Content-Type': 'application/json',
  21. 'dataType' : 'json'
  22. },
  23. type: "POST",
  24. url : 'addItem',
  25. data : array,
  26. success : function(result) {
  27. document.formulario.submit();
  28. },
  29. error: function (jqXHR, textStatus, msg) {
  30. alert(msg);
  31. }
  32. });
  33. }
  34.  
  35. @RequestMapping(value = "addItem", method = RequestMethod.POST)
  36. public @ResponseBody
  37. void addItem(@RequestBody ItemEntrada[] array,HttpServletRequest request) {
  38. /*
  39. * ações do metodo
  40. */
  41. }
  42. }
  43.  
  44. var array =
  45. [
  46. {"quantidade":"1","valorUnd":10,"produto":
  47. {"id":"1","grades":[{"propriedade":{"id":"2"},"classe":{"id":"1"}}]}
  48. }
  49. ];
  50.  
  51. var array =
  52. [
  53. {"quantidade":"1","valorUnd":10,"produto":
  54. {"id":"1"}
  55. },
  56. {"quantidade":"1","valorUnd":10,"produto":
  57. {"id":"2"}
  58. },
  59. {"quantidade":"1","valorUnd":10,"produto":
  60. {"id":"3"}
  61. }
  62. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement