Guest User

Untitled

a guest
Jan 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. $(document).ready(function()
  2. {
  3. $("#form1").validationEngine({
  4. ajaxSubmit: true,
  5. ajaxSubmitFile: "note/note.php",
  6. success: false
  7. });
  8. if (success == "true")
  9. {
  10. function()
  11. {
  12. window.alert("Report Sent!");
  13. //write a confirmation to the user
  14. document.getElementById("update").innerHTML="Report Sent!";
  15. setTimeout(function()
  16. {
  17. document.getElementById("update").innerHTML="";
  18. },3000);
  19. }
  20. }
  21. });
  22.  
  23. $(document).ready(function()
  24. {
  25. $("#form1").validationEngine({
  26. ajaxSubmit: true,
  27. ajaxSubmitFile: "note/note.php",
  28. success: false
  29. });
  30.  
  31. if (success == "true")
  32. {
  33. function()
  34. {
  35.  
  36. $(document).ready(function()
  37. {
  38. $("#form1").validationEngine({
  39. ajaxSubmit: true,
  40. ajaxSubmitFile: "note/note.php",
  41. success: function(response)//response is what the php script returns
  42. {
  43. //the function from your if branch goes here
  44. }
  45. });
  46.  
  47. $(document).ready(function()
  48. {//notice the curly braces around what you're passing to validationEngine
  49. $("#form1").validationEngine({
  50. ajaxSubmit: true,
  51. ajaxSubmitFile: "note/note.php",
  52. success: function(response)
  53. {
  54. if (response !== 'true')
  55. {
  56. if (window.console)
  57. {
  58. console.log(response);
  59. alert('check your console to see the response');
  60. }
  61. else
  62. {
  63. alert(response);
  64. }
  65. return;
  66. }
  67. alert("Report Sent!");//no need for window here
  68. document.getElementById("update").innerHTML="Report Sent!";
  69. setTimeout(function()
  70. {
  71. document.getElementById("update").innerHTML="";
  72. },3000);
  73. }
  74. });
  75. //As I said, you're passing an object, so you could write the code above like so:
  76. var validationArgs = {ajaxSubmit:true,ajaxSubmitFile:'note/note.php'};
  77. validationArgs.success = function()
  78. {
  79. //your function
  80. };
  81. $('#form1').validationEngine(validationArgs);
  82. });
  83.  
  84. $(document).ready(function() {
  85. var update = $("#update");
  86. // Callback
  87. var onSuccess = function() {
  88. alert("Report Sent!");
  89.  
  90. //write a confirmation to the user
  91. update.html("Report Sent!");
  92.  
  93. setTimeout(function(){
  94. update.html("");
  95. },3000);
  96. };
  97.  
  98. $("#form1").validationEngine({
  99. ajaxSubmit: true,
  100. ajaxSubmitFile: "note/note.php",
  101. success: onSuccess
  102. });
  103. });
Add Comment
Please, Sign In to add comment