Guest User

Untitled

a guest
Jan 15th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. $(".submitinfo").each(function() {
  2. // Want to use ID as POST name
  3. // And value as POST value
  4. });
  5. // Submit the data
  6. $.ajax({
  7. url: 'submit.php',
  8. traditional: true,
  9. data: {
  10. 'submit':'true',
  11. 'age':$('#age').val(),
  12. 'loss':$('#loss').val()
  13. // somehow include results here
  14. },
  15. type: 'POST',
  16. async: false,
  17. success: function(data) {
  18. alert(data);
  19.  
  20. },
  21. error: function() {
  22. alert('Submit Error');
  23. }
  24. });
  25.  
  26. var data = {
  27. submit : 'true',
  28. age : $('#age').val(),
  29. loss : $('#loss').val()
  30. }
  31.  
  32. $(".submitinfo").each(function() {
  33. data[this.id]=this.value;
  34. });
  35.  
  36. $.ajax({
  37. url: 'submit.php',
  38. traditional: true,
  39. data: data,
  40. type: 'POST',
  41. async: false,
  42. success: function(data) {
  43. alert(data);
  44. },
  45. error: function() {
  46. alert('Submit Error');
  47. }
  48. });
  49.  
  50. var data = {};
  51. $('.submitinfo').each(function() {
  52. var el = $(this),
  53. id = el.attr('id'),
  54. val = el.val();
  55.  
  56. data[id] = val;
  57. });
  58.  
  59. $.ajax({
  60. url: 'submit.php',
  61. traditional: true,
  62. data: data,
  63. type: 'POST',
  64. async: false,
  65. success: function(data) {
  66. alert(data);
  67. },
  68. error: function() {
  69. alert('Submit Error');
  70. }
  71. });
  72.  
  73. $.post(url, $('form').serialize(), function(data) {
  74. alert("Success");
  75. });
Add Comment
Please, Sign In to add comment