Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <script>
  2.  
  3. function Save() {
  4. $(document).ready(function () {
  5. var things = [
  6. { id: 1, color: 'yellow' },
  7. { id: 2, color: 'blue' },
  8. { id: 3, color: 'red' }
  9. ];
  10.  
  11. things = JSON.stringify({ 'things': things });
  12.  
  13. $.ajax({
  14. contentType: 'application/json; charset=utf-8',
  15. dataType: 'json',
  16. type: 'POST',
  17. url: '/PassThings',
  18. data: things,
  19. success: function () {
  20. alert("success");
  21. },
  22. failure: function (response) {
  23. alert(response);
  24. }
  25. });
  26. });
  27.  
  28. }
  29.  
  30. </script>
  31.  
  32. <input type="button" value="Pass Things" onclick="JavaScript: Save();">
  33.  
  34. public class Thing
  35. {
  36. public int Id { get; set; }
  37. public string Color { get; set; }
  38. }
  39.  
  40. public void PassThings(List<Thing> things)
  41. {
  42. var t = things;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement