ajax timeout

1 posts, 0 answers
  1. sho
    sho avatar
    24 posts
    Member since:
    Mar 2007

    Posted 13 Mar 2015 Link to this post

    Hi

      I am using the below code in my index page
    <script>
      $(function () {
            if (somecondition) {
                getresult();
            }
            if (anothercondition > 0) {
               setTimeout(function () {
                    if (result.toLowerCase() == "true") {
                        window.location.href = "goto result page;
                    }
                    else {
                        window.location.href = "goto index page";
                    }
                }, 9000);
            }
        });

    function getresult() {
            $.ajax({
                url: '@Url.Action("action", "controller")',
                data: {
                    param1: 0
                },
                type: 'GET',
                async: true,
                contentType: "application/json;charset=utf-8",
                cache: false,
                success: function (data) {
                    result = data
                },
                error: function (x, t, m) {
                    result = "FAILURE"
                }
            });
        }
    </script>

    I would like to navigate to some other view ex: "sample/failedstatus"
    How can I do, as though I place the code something like below i am not able to redirect page 

      error: function (x, t, m) {
        window.location.href = "test/sample/failedstatus";
                    result = "FAILURE"
                }

    Can anyone help me how can I do this?

    Thanks in advance








Back to Top