开发者

redirect after webmethode

I'm using javascript to send a array to my code behind so it can be saved. And also to redirecting the 开发者_StackOverflowpage to the next dataset.

function ChangeMonth(utcDate){
        PageMethods.javaGetArray(colors);
        alert("saving...");
        window.location = "./transport.aspx?date=" + utcDate;
    }

This works perfectly when there's an alert in between, the saving and the redirect. If I delete the alert it just redirects without saving.

Any thoughts?


This is because the browser redirects before it has any time for the AJAX request to complete. You could use the provided callback to perform the redirect:

PageMethods.javaGetArray(colors, function(result) {
    window.location = './transport.aspx?date=' + utcDate;
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜