This is a migrated thread and some comments may be shown as answers.

ajax timeout

0 Answers 13 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
sho
Top achievements
Rank 1
sho asked on 13 Mar 2015, 06:30 AM
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








No answers yet. Maybe you can help?

Tags
Ajax
Asked by
sho
Top achievements
Rank 1
Share this question
or