Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. <script>
  2. $('#sbmt').click( function(){
  3. $.ajax({
  4. type: 'post',
  5. data: $("#ajxfrm").serialize(),
  6. url: "postdata.php",
  7. cache: false,
  8. success: function (data)
  9. {
  10. alert('updated table');
  11. }
  12. });
  13. });
  14. </script>
  15.  
  16. <form id="ajxfrm" method="post" action="">
  17.  
  18. <label>HIGH : </label> <input type="text" name="hi" id="hi"><br><br>
  19.  
  20. <label>LOW : </label><input type="text" name="lo" id="lo"><br><br>
  21.  
  22. <label>OPENING STOCK : </label><input type="text" name="opn" id="opn"><br><br>
  23.  
  24. <label>CLOSING STOCK : </label><input type="text" name="cls" id="cls">
  25.  
  26. <input type="submit" value="Submit" id="sbmt">
  27.  
  28. </form>
  29.  
  30. require_once 'config.php';
  31.  
  32. $hi = $_POST['hi'];
  33.  
  34. $lo = $_POST['lo'];
  35.  
  36. $opn = $_POST['opn'];
  37.  
  38. $cls = $_POST['cls'];
  39.  
  40. echo $hi;
  41.  
  42. $postdata = "INSERT INTO htmdem ( high,low,open,close ) VALUES('$hi','$lo','$opn','$cls');";
  43.  
  44. mysql_query($postdata);
  45.  
  46. jQuery(function($) {
  47. $('#ajxfrm').submit( function(e){
  48. $.ajax({
  49. type: 'post',
  50. data: $(this).serialize(),
  51. url: $(this).attr("action")
  52. })
  53. .done(function (data){
  54. alert('updated table');
  55. });
  56. e.preventDefault();
  57. });
  58. });
  59.  
  60. <form id="ajxfrm" method="post" action="postdata.php">
  61.  
  62. $('#ajxfrm').submit(function(event){
  63. $.ajax({
  64. type: 'post',
  65. data: $(this).serialize(),
  66. url: $(this).attr("action"),
  67. cache: false,
  68. success: function (data)
  69. {
  70. alert('updated table');
  71. }
  72. });
  73. return false; //to prevent form submission
  74. //or event.preventDefault();
  75. });
  76.  
  77. $('#ajxfrm').submit(function(event){
  78. $.ajax({
  79. type: 'post',
  80. data: $(this).serialize(),
  81. url: $(this).attr("action")
  82. })
  83. .done(function (data){
  84. alert('updated table');
  85. });
  86. return false; //to prevent form submission
  87. //or event.preventDefault();
  88. });
  89.  
  90. mysql_query($postdata) or die(mysql_error());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement