开发者

redirect after webmethode

开发者 https://www.devze.com 2022-12-18 06:36 出处:网络
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.

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

精彩评论

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

关注公众号