Redirect after Ajax Post

Redirect after Ajax Post

Hi,

I am using below code to post form data to MySQL.. It's all working fine except the redirect after post success. I don't get any error in the console and data are being submitted successfully as I have see in MySQL but the redirect is not happening so it will just stay on the same page.

Where is the problem? with thanks...

  1. <script type="text/javascript">
  2. $(document).ready(function()
  3. {
  4. // $(function() { $("#btnSave").button(); });
  5.     // $(function() { $("#btnCancel").button(); });
  6. $("#btnSave, #btnCancel").button();
  7.     
  8. $("#frmLeave").validate({
  9. invalidHandler: function()
  10. {
  11. $.fn.speedoPopup(
  12. {
  13. width: 300,
  14. height: 100,
  15. loadingImage: true,
  16. close: true,
  17. draggable: false,
  18. caption: "Error",
  19. htmlContent: "<b>Please fill all required fields!</b>"
  20. // htmlContent: validator.errorList[0].message
  21. });
  22. },
  23. rules:
  24. {
  25. cboCategory:
  26. {
  27. required: true
  28. },
  29. dateFrom:
  30. {
  31. required: true
  32. },
  33. dateTo:
  34. {
  35. required: true
  36. }
  37. },
  38. submitHandler: function (form)
  39. {
  40. $("#imgLoader").show();
  41. $("#lblLoader").show();
  42. $("#btnSave").hide();
  43. $("#btnCancel").hide();
  44. $("#btnSave").attr("disabled", true);
  45. // $(form).submit();

  46. $.ajax({
  47. type: 'POST',
  48. url: "submit_leave.php",
  49. dataType: "json",
  50. data: $('#frmLeave').serialize(),
  51. success: function()
  52. {
  53. window.location.href = '<?php echo $_SESSION["bluefile_domain_name"]; ?>my';
  54. }
  55. });
  56. // $(form).ajaxSubmit();
  57. // return false;
  58. }
  59. });
  60.     $('#btnCancel').click(function() { window.location = '<?php echo $_SESSION["bluefile_domain_name"]; ?>my'; });
  61. });
  62. </script>