views:

25

answers:

1

Hi, I'm using javascript to send a array to my code behind so it can be saved. And also to redirecting the page 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?

+1  A: 

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;
});
Darin Dimitrov
my mistake ;) Works perfectly
Tetting