Advertisement
Guest User

Untitled

a guest
Jul 31st, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. <form id="formoid" action="studentFormInsert.php" title="" method="post">
  2. <div><label class="title">First Name</label><input type="text" id="name" name="name" ></div>
  3. <div><label class="title">Name</label><input type="text" id="name2" name="name2" ></div>
  4. <div><input type="submit" id="submitButton" name="submitButton" value="Submit"></div>
  5.  
  6. <script type="text/javascript">
  7. $(document).ready(function() {
  8. $('#formoid').ajaxForm(function() {
  9. alert("Thank you for your comment!");
  10. });
  11. });
  12. </script>
  13.  
  14. <!DOCTYPE html>
  15. <html>
  16. <head>
  17. <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  18. </head>
  19. <body>
  20. <form id="formoid" action="studentFormInsert.php" title="" method="post">
  21. <div>
  22. <label class="title">First Name</label>
  23. <input type="text" id="name" name="name" >
  24. </div>
  25. <div>
  26. <label class="title">Name</label>
  27. <input type="text" id="name2" name="name2" >
  28. </div>
  29. <div>
  30. <input type="submit" id="submitButton" name="submitButton" value="Submit">
  31. </div>
  32. </form>
  33. <script type='text/javascript'>
  34. /* attach a submit handler to the form */
  35. $("#formoid").submit(function(event) {
  36.  
  37. /* stop form from submitting normally */
  38. event.preventDefault();
  39.  
  40. /* get some values from elements on the page: */
  41. var $form = $( this ),
  42. url = $form.attr( 'action' );
  43.  
  44. /* Send the data using post */
  45. var posting = $.post( url, { name: $('#name').val(), name2: $('#name2').val() } );
  46.  
  47. /* Alerts the results */
  48. posting.done(function( data ) {
  49. alert('success');
  50. });
  51. });
  52. </script>
  53.  
  54. </body>
  55. </html>
  56.  
  57. $.post("test.php", $("#testform").serialize());
  58.  
  59. <!DOCTYPE html>
  60. <html>
  61. <head>
  62. <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  63. </head>
  64. <body>
  65. <form action="/" id="searchForm">
  66. <input type="text" name="s" placeholder="Search..." />
  67. <input type="submit" value="Search" />
  68. </form>
  69. <!-- the result of the search will be rendered inside this div -->
  70. <div id="result"></div>
  71. <script>
  72. /* attach a submit handler to the form */
  73. $("#searchForm").submit(function(event) {
  74.  
  75. /* stop form from submitting normally */
  76. event.preventDefault();
  77.  
  78. /* get some values from elements on the page: */
  79. var $form = $(this),
  80. term = $form.find('input[name="s"]').val(),
  81. url = $form.attr('action');
  82.  
  83. /* Send the data using post */
  84. var posting = $.post(url, {
  85. s: term
  86. });
  87.  
  88. /* Put the results in a div */
  89. posting.done(function(data) {
  90. var content = $(data).find('#content');
  91. $("#result").empty().append(content);
  92. });
  93. });
  94. </script>
  95. </body>
  96. </html>
  97.  
  98. var postData = "text";
  99. $.ajax({
  100. type: "post",
  101. url: "url",
  102. data: postData,
  103. contentType: "application/x-www-form-urlencoded",
  104. success: function(responseData, textStatus, jqXHR) {
  105. alert("data saved")
  106. },
  107. error: function(jqXHR, textStatus, errorThrown) {
  108. console.log(errorThrown);
  109. }
  110. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement