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;
});
精彩评论